Look at the example code and think about how to reverse the logic. It starts at 0 and ends at 4, you need to start at 5 and end at 0. You have the correct start and you are decrementing the value as needed, but your end condition isn’t correct (the while condition starts off false).
It is just an example to show you the conditional logic is wrong.
The while condition works just like an if statement. It is evaluated and if the condition is false it never enters the body. An if statement is only evaluated one time, the while statement is evaluated at the start of each iteration. You never enter the body of your while loop.
You first want to choose a different operator since the less than operator is not going to work.
Then you need to change the number here
If it helps to write down the logic down on pen and paper, then I would suggest that.
You first want to push 5 to the array, then 4, 3,2,1,0
Then think about how you can translate that to code for your while loop.
Ok, I just wanted to point out which part of the code is wrong (my experince is that sometimes people might to see the solution to understand what is wrong or to ask a question, but I get your point too… just acted on my personal experience of training junior devs)…
So I will try to give a hint then…
The code is running when the i < 5, so you that is what is not giving you the desired output.
Remember that you need to run the code first when the i = 5, then you decrease the value by one, so on next iteration the i = 4 snd you again decrease the value by 1… and you need it run the last time when the value is 0.