Tell us what’s happening:
Hi all, just wondering why you cannot Splice in array into another array? When I do a console.log it seems to return a similar result. Well not exactly. In the result field in freeCodeCamp it returns something like:
4,1,2,3,5,6
However in Chrome Dev tools it returns: [4, Array3, 5, 6] which still has the same numbers in sequence. It just doesn’t display them like [4, 1, 2, 3, 5, 6] as it would if you loop through and splice them in individually. Is this not passing the tests because it is looking for them displayed as in the loop method?
Thanks!
Your code so far
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
var newArr = arr2.slice();
newArr.splice(n, 0, arr1);
console.log(newArr);
return newArr;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:69.0) Gecko/20100101 Firefox/69.0
.
Link to the challenge: