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

Not accepting the test
The test is not accepting my solution even though the console output seems the same as the desired one, except for the double quotes.

Your code so far

function mixedNumbers(arr) {
  // Only change code below this line
  arr.push(7, "VIII", 9);
  arr.unshift("I", "2", "three");
  // Only change code above this line
  return arr;

console.log(mixedNumbers(['IV', 5, 'six']));

Console output

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

Your browser information:

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

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

Link to the challenge:

watch out on the datatype , number or string… :melting_face:

1 Like

@WongYC-66 Thanks, but I do not think that is the issue I tried that too.

Using ‘2’ instead of 2 is definitely a problem.

Yes, it should be, but please check the non-editable line also have such mix values and the previous lesson was about mix values as well. And I tried with

arr.push("7", "VIII", "9");
arr.unshift("I", "2", "three");

It did not accepted the solution, then I tried changing 5 to “5” no effect.

Did you try fixing the 2 here?

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.

The instructions don’t show quotation marks around the 2, 7, or 9, so you should not put quotation marks around them.

If I fix the data types to what the instructions give, then your code passes. You must use numbers instead of strings for those 3 values.

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