Tell us what’s happening:
I don’t really have a problem on this topic but I just want to ask if this code is fine? It works but I’m not satisfied, I don’t know because the solution is different from mine haha lol.
Your code so far
function frankenSplice(arr1, arr2, n) {
let newArr = [...arr2]
newArr.splice(n,0,...[...arr1]);
return newArr;
}
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/105.0.0.0 Safari/537.36 OPR/91.0.4516.95
Challenge: Basic Algorithm Scripting - Slice and Splice
Hello, sir, thank you for replying. On that part, without the first spread operator, it would be a nested array like this [ 4, [1,2,3], 5, 6 ]. So I think I should really put that operator. But then I think it was not a best practice or maybe it’s acceptable.