Hi guys,i am trying to use splice() to put in copied element in arr1 to arr2
**Your code so far**
function frankenSplice(arr1, arr2, n) {
let joinArr = arr1.slice();
for (let i = 0; i < arr1.length; i++)
joinArr = arr2.splice()
n++
return joinArr;
}
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; rv:97.0) Gecko/20100101 Firefox/97.0
Challenge: Slice and Splice
Link to the challenge:
ilenia
2
You will need to give some arguments to the methods, maybe look up how the method works
function frankenSplice(arr1, arr2, n) {
let joinArr = arr2.slice();
for (let i = 0; i < arr1.length; i++) {
joinArr.splice(n, 0, arr1[i]);
}
n++;
return joinArr;
}
console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));
why is it returning this [ 4, 3, 2, 1, 5, 6 ] instead of this [4, 1, 2, 3, 5]
ilenia
4
You are putting each number at index n
, you would get the numbers reversed for that
system
Closed
5
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.