That’s exactly what I came up with too. Didn’t work though.
removing the blank array “myArray” that was written there helped a little but after the console returned a 4 instead of the “[]”(without the quote), that it returned before.
It’s exactly the same code as the OP…[quote=“Rafase282, post:1, topic:18220”]
var ourArray = [];
var i = 0;
while(i < 5) {
ourArray.push(i);
i++;
}
[/quote]
Just so you all know in case you haven’t noticed, this shows how to use what they are asking, it is not however, necessarily the right answer that you can just copy paste.
I originally created these long ago but I remember not putting the right answer as the example even though in many cases it would be the same or very similar.
yup, I derped like in the OP I guess. I changed my code from ourArray to myArray and it worked. Of course maybe he did his on purpose I’m the one that derped… anyway, thanks guys!
Your github wiki has helped me tremendously in the past. When I get stuck, it’s the first place I turn. I like how they are so similiar it helps me understand. it’ helps with the streategy of problem, solving sometimes and it also helps tro show me that sometimes I’m way off whewre I should be.
Some of the lessons have apparently been changed since you did your work but even still, I’m still learning.
So please don’t feel like you need to defend yourself. You’ve helped a ton (at least for me and I suyspect, many others).
Note the importance of the increment ( i++) after the .push and not before it. If the i++ is added before the .push you will get the output of 1-5 and not 0-4.
var myArray = [];
var i=0;
while (i<5){
myArray.push(i);
i++;