EQuimper / CodeChallenge

All my thinking about some code challenge and Free Code Camps
283 stars 196 forks source link

Update Iterate with JavaScript While Loop #12

Open giorgioGTelian opened 1 year ago

giorgioGTelian commented 1 year ago

They changed the exercise! (again)

Ajackwere commented 1 year ago

Just a question, do you think the code will execute when i = -1?

giorgioGTelian commented 1 year ago

if you write let i = -1 the output will be [5, 4, 3, 2, 1, 0, -1] so our Array will begin at -1 inclusive.

this is the complete code with the change you suggested const myArray = []; // Only change code below this line let i = -1; while (i < 6) { myArray.push(i); i++; } // Only change code below this line. myArray.reverse(myArray); console.log(myArray);