Add Items to an Array with push() and unshift(), test correct why is it not passing?

Tell us what’s happening:
I don’t understand why it’s not passing. Test the output and it’s correct result.

Your code so far


function mixedNumbers(arr) {
  // change code below this line
    let arr1 = ['I', 2, 'three'];
    let arr2 = [7, 'VIII', 9];
    arr.unshift(arr1);
    arr.push(arr2);
  // change code above this line
  return arr;
};

// do not change code below this line
console.log(mixedNumbers(['IV', 5, 'six']));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-data-structures/add-items-to-an-array-with-push-and-unshift

Your push and unshift commands are each adding a single element containing an array to arr (creating nested arrays). You need a one-dimensional array.

1 Like

^^ yup. You’re making it a two dimensional array, not one dimension.

(I just got past this one this afternoon)

1 Like

Thank you for your help!