Basic JavaScript - Manipulate Arrays With push Method

Tell us what’s happening:

Describe your issue in detail here.

I have a silly question. In the sample code, I am presented with two push examples. The first “arr1.push(4, 5);” utilises only parentheses, while the second utilises both parentheses and brackets (). I wonder why the difference? Couldn’t the second one simply have been written as arr2.push(“happy”, “joy”); and still have worked?
I thank you for your time and kindness!

Your code so far

const arr1 = [1, 2, 3];
arr1.push(4, 5);

const arr2 = ["Stimpson", "J", "cat"];
arr2.push(["happy", "joy"]);


Your browser information:

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

Challenge Information:

Basic JavaScript - Manipulate Arrays With push Method

Here you are pushing two things, the number 4 and the number 5

Here you are pushing one thing, an array holding two words

1 Like

Right, right, you are. I did not notice. I feel so silly. Thanks a million!

2 Likes

No worries, this is new stuff

2 Likes

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