Basic JavaScript: Iterate with JavaScript Do...While Loops

Basic JavaScript: Iterate with JavaScript Do...While Loops
0.0 0

#1

In the curriculum update this topic has been included, I get how this works I just wonder why you would ever use it. are there examples of when this would be desired? Couldn’t you just declare a variable with the value you want to log from this do while loop? or is this just included to help us debug problems if somehow we mess up a while loop and see that it’s not iterating correctly because we included a do?


#2

share the link to the challenge


#3

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/iterate-with-javascript-do---while-loops


#4

randelldawson added it below. sorry for not including it initally.


#5

do…while is only really useful for times when you really need to execute some statement before checking if it’s truthy. You’ll hardly ever need it, but you may see some in the wild.