Something wrong with ? "array.push(value)"?

hi, iam learning javascript and please look at the code below:

anyone can explain for me?

Hey sorry i don’t understand what you are asking please can u elaborate more?

sorry, wait me for a minute

ok, let s take a look, please. And explain for me . thanks

The push() method adds one or more elements to the end of an array and returns the new length of the array.

1 Like

oh!!!, ah ha, thank you so much. I spent this afternoon thinking that “what is wrong with this”.
thank you :slight_smile:

1 Like


  1. You don’t have to use other online IDE for testing output, you can code on freeCodeCamp IDE…Add your code at the bottom and it will show results in output window.

  2. arr.push(n) is showing length of the array. What is means is arr.push(n) return always length. So when you do arr.push(10), your arr becomes arr=[10]. When you do arr.push(9) your arr becomes arr=[10,9]. So in output you see length of the array followed by "why " and value of n copy your code here and see it by your self it’s easy

1 Like

thanks,i think the code editor of freecodecamp seem to be not reliable :blush:

1 Like

You can choose whatever you think is best. I use freeCodeCamp, pythontutuor and hand-running thr program

1 Like