It says its wrong Add Items to an Array with push() and unshift()

im not sure whats wrong

Tell us what’s happening:

Your code so far


function mixedNumbers(arr) {
  // change code below this line
arr.unshift(['I', 2, 'three']);
arr.push(['7', 'VIII', 9,]);
  // 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 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 approach is correct.
You just have one issue.
Lets take one of the test cases as example.
The challenge wannts mixedNumbers(['IV', 5, 'six']) to return:

["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]

Whereas your code returns:

[["I", 2, "three"], "IV", 5, "six", [7, "VIII", 9]]

See if you can solve that.
All the best.
Tip: Try using chrome’s console(Press F12 key in your browser) to see what your code returns.

1 Like