How to Manipulate Arrays With unshift()

Tell us what’s happening:

Your code so far


// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.shift(); // ourArray now equals ["J", "cat"]
ourArray.unshift("Happy"); 
// ourArray now equals ["Happy", "J", "cat"]

// Setup
var myArray = [["John", 23], ["dog", 3]];
myArray.shift();

// Only change code below this line.
myArray.unshift("Paul", 35);


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/manipulate-arrays-with-unshift

In myArray, you shift an element that happens to be an array.
May be you should as well unshift an other array and not just a string and a number.
Hope it helps !

1 Like

This is the solution.
You need to pass the [] object:
myArray.unshift([“Paul”,35]);

Thank you I get it solved