I don’t understand whether should I turn each array element into a character but stored it in an array, should I?
If so, I tried this with map, trying to map each element to toString
. So, what am I doing wrong?
function frankenSplice(arr1, arr2, n) {
arr1.slice(0);
let array2Copy = arr2.slice(0);
for (let i = 0; i < arr1.length; i++){
array2Copy.splice(n, 0, arr1[i]);
}
let result = array2Copy.map(i => i.toString());
return result;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1));//-->4,3,2,1,5
frankenSplice([1, 2], ["a", "b"], 1);//-->a,2,1,b