My question is, if I move “let para = document.createElement(‘p’);” above and out of the loop, it just displays “Blast Off!”
But I’m not sure why that’s happening.
In my head, once the para variable is defined, the loop will just write over it with para.textContent, and that will be appended to output with each loop. I’m not sure why it has to be defined within the loop?
last statement in the while loop should be i-- not i–
when it defined inside the loop that mean each iteration a variable will be created then you set it’s textContent to countdown or i or blast
then you append it to the output element
I’m still confused - why does it matter if the value is defined outside vs inside - even if it’s defined outside won’t it be overwritten by the loop anyway?
right click on the result area then inspect you will see the html pane include 10 p element when the para inside the loop and if you move it outside the loop there will be only 1 p element inside the div element