Basic Algorithm Scripting - Slice and Splice Numbers Concatenating Instead of Summing

Tell us what’s happening:
I thought this would work but its logging out 10, 11, 12 instead of the expected 1, 2 ,3
I’ve done some googling and it seems I’d have to manually add an empty string to concatenate numbers rather than sum them.

Your code so far

function frankenSplice(arr1, arr2, n) {
  let returnArr = arr2;
  for (let i in arr1){
    console.log(n + i);
    returnArr.splice(n + i, 0, arr1[i]);

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/ Safari/537.36

Challenge: Basic Algorithm Scripting - Slice and Splice

Link to the challenge: loops are for objects. I think you want for..of.

Also, don’t forget to return your array.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.