Iterate with JavaScript While Loops. Test

I tried the test and this was how I managed to pass.
Any comments or alternative style is welcomed.

// solution to the test.

var i = 0;
while(i <= 5) {
    myArray.push(i);
    i++;
    myArray.sort();
    myArray.reverse();
}

it is unnecessary complicated.
Try solving it with just the push method. You would need to change a couple of things, but it’s totaly doable

Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thank you.


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums