Tell us what’s happening:
I have a question in this challenge after read a solution :
why my output from frankenSplice(code below) is return empty array but if i return only strOut next line , it passed ?
Your code so far
function frankenSplice(arr1, arr2, n) {
let strOut = arr2.slice();
return strOut.splice(n,0,...arr1);
}
console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36.
if my code is
function frankenSplice(arr1, arr2, n) {
let strOut = arr2.slice();
return strOut.splice(n,0,…arr1);
}
(frankenSplice([1, 2, 3], [4, 5, 6], 1));
Output:
but if my code is
function frankenSplice(arr1, arr2, n) {
let strOut = arr2.slice();
strOut.splice(n,0,…arr1);
return strOut;
}
(frankenSplice([1, 2, 3], [4, 5, 6], 1));