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.
oh!!!, ah ha, thank you so much. I spent this afternoon thinking that “what is wrong with this”.
thank you
Hey
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.
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
http://www.pythontutor.com/live.html#mode=edit copy your code here and see it by your self it’s easy
Thanks
thanks,i think the code editor of freecodecamp seem to be not reliable
You can choose whatever you think is best. I use freeCodeCamp, pythontutuor and hand-running thr program