Manipulate Arrays With push() - this should be correct?

Tell us what’s happening:

Your code so far


// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]); 
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]

// Setup
var myArray = [["John", 23], ["cat", 2]];

// Only change code below this line.

myArray.push("dog", 3);

Your browser information:

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

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

The problem is here, in the following line:

The challenge is asking you to push an array: ["dog", 3] but you pushed only separated data: a string and an integer: "dog", 3.

The first will result in this: var myArray = [["John", 23], ["cat", 2], ["dog", 3]];
The second will result in this: var myArray = [["John", 23], ["cat", 2], "dog", 3]; and this is not what the challenge is asking.

I hope this was helpful,
and it’s up to you now to push the array ["dog", 3] into myArray.

2 Likes

yup, that’s helpful THANKS

No problem.

Good Luck & Happy Coding.