Tell us what’s happening:
I tried to solve this by using spread syntax or rest parameter.
This does not work on FCC and Google Chrome console returning an empty array.
However, it works on MDN JS Demo of Splice Docs.
Can someone help me clear this confusion?
TYIA
Your code so far
FCC codes:
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
return arr2.splice(n, 0, ...arr1);
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
MDN codes:
var months = ['Jan', 'March', 'April', 'June'];
var months2 = ['Jan', 'March'];
months.splice(1, 0, ...months2);
Output: ["Jan", "Jan", "March", "March", "April", "June"]
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice/
Link to the MDN Splice: