I do not understand this challange

i honestly did not understand how we arrived at the final answer to this challange.i was only able to do this through the video.my question is how did the we get this ([“dog”, 3])

Your code so far


// 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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.67

Challenge: Manipulate Arrays With push()

Link to the challenge:

What parts of this are you not understanding? I can help explain how the .push method works if that would help!

do the actually mean that this ([“dog”, 3]) should be at the end of this [[“John”, 23], [“cat”, 2]]

Maybe try this code to see how the solution works!

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

// Only change code below this line
myArray.push(["dog", 3]);

console.log(myArray);

The console.log() will show you the new value of myArray, which now includes the array ["dog", 3].

The .push() function adds whatever parameters you pass into it to the end of the array that you are accessing.

thanks buddy.i appreciate you

1 Like

Of course! I hope the .push() function makes more sense to you now!

ya hommie,i appreciate you. could we learn together?? i would not mind if you give me other access to reach you apart from freecodecamp

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