Answer the question
In order to leave comments, you need to log in
Why is it necessary to create a new variable every time when working with methods?
Good morning, tell me why you can not write like this?
var str = "car";
str.split().splice(1,0, "is black");
var str = "car";
var res = str.split().splice(1,0, "is black");
var str = "car";
var res = str.split();
res.splice(1,0, "is black");
var str = "car";
var res = str.split();
res.splice(1,0, "is black");
res.join("");
res.join("")
Answer the question
In order to leave comments, you need to log in
splice modifies an array, but returns not the modified array, but what was removed. You have 0 elements removed, so the return value is an empty array.
It's not clear why you use splice at all in this example.
You can throw everything away and write simply:"car is black"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question