"Basic Data Structures: Add Items to an Array with push() and unshift()" not passing with correct answer?

so I think I’ve written this out right but it’s still not passing even with console.log() showing the correct result.

would someone please explain what is going wrong here?

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"]));
// running tests
mixedNumbers(["IV", 5, "six"]) should now return ["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]
// tests completed

Why are you pushing and unshifting an array? It is asking for one array, not an array of arrays.

Hint: Those methods take an infinite amount of arguments.

this is what the course is asking of me:

Basic Data Structures: Add Items to an Array with push() and unshift()

An array’s length, like the data types it can contain, is not fixed. Arrays can be defined with a length of any number of elements, and elements can be added or removed over time; in other words, arrays are mutable. In this challenge, we will look at two methods with which we can programmatically modify an array: Array.push() and Array.unshift() .

Both methods take one or more elements as parameters and add those elements to the array the method is being called on; the push() method adds elements to the end of an array, and unshift() adds elements to the beginning. Consider the following:

let twentyThree = ‘XXIII’;
let romanNumerals = [‘XXI’, ‘XXII’];

romanNumerals.unshift(‘XIX’, ‘XX’);
// now equals [‘XIX’, ‘XX’, ‘XXI’, ‘XXII’]

// now equals [‘XIX’, ‘XX’, ‘XXI’, ‘XXII’, ‘XXIII’]

Notice that we can also pass variables, which allows us even greater flexibility in dynamically modifying our array’s data.

We have defined a function, mixedNumbers , which we are passing an array as an argument. Modify the function by using push() and unshift() to add 'I', 2, 'three' to the beginning of the array and 7, 'VIII', 9 to the end so that the returned array contains representations of the numbers 1-9 in order.

Yes, but it’s not asking to push an array of those items to the beginning and end.

oh wait. I think i understand what you’re saying to me now.
sorry my bad.

1 Like

click on the blurred hint if you need one

I suggest you copy your code and paste it in the browser console

Or use this tool: http://pythontutor.com/javascript.html

So you see better what’s going on

1 Like

Oh wow. sorry guys, I was completely overlooking something so obvious. Thank you for your help!