Add Items to an Array with push() and unshift()

Add Items to an Array with push() and unshift()
0.0 0

#1

Tell us what’s happening:
what did I missing?

Your code so far


function mixedNumbers(arr) {
  // change code below this line
arr.push("I", 2, "three");
arr.unshift(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/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/


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

.push is going to the last array another one not


#3

HI @arduino731,

This is the solution of example:

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

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

Hope this help you, good luck and keep going up :muscle:t2:

Regards,
Ali Mosaad


#4

The best way needs to be


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

Blockquote

`


#5

You can use very simple method to pass this test and is very easy.

arr.splice(0, 1 ,“DarkSalmon”);
arr.splice(1, 1, ‘BlanchedAlmond’);

This will save time of yours.