Add Items push() and unshift() style

Tell us what’s happening:
I really don’t get it… I understood the idea, I pushed to the end 7 VIII 9 and at the begining I 2 III

This code should pass right? Is there a logic or something I missed?
Thanks for the help.

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 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 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

Okay, even this doesn’t pass…

let seven = 7
let eight = "VIII";
let nine = 9;
arr.push(seven);
arr.push(eight);
arr.push(nine);

Very confusing to me.

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;
}

you are adding items as an array `arr.push( [7,"VIII, 9]  )`

try this arr.push(7,"VIII",9);

Okay, the confusion was exactly this, as I pushed things to an array, I was thinking that making an array, as there are many arguments, was the thing to do. Thanks, it helped me t understand =).

1 Like

happy coding , keep learning

1 Like