Tell us what’s happening:
I don’t know why the iterator is adding numbers in this format while performing splice operation…
How to resolve this??
I’m getting the output in this format!!
[ 4, 3, 2, 1, 5, 6 ]
Your code so far
function frankenSplice(arr1, arr2, n) {
let array = arr2.slice();
for (let i=1; i <=arr1.length;) {
array.splice(n,0,i);
i++;
}
return array;
}
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/110.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Slice and Splice
Link to the challenge: