Why use a "do while" loop?
- by Stanni
Hi,
I've never understood why using a do while loops is necessary. I understand what they do, Which is to execute the code that the while loop contains without checking if the condition is true first.
But isn't the below code:
do{
document.write("ok");
}
while(x == "10"){
document.write("ok");
}
The exact same as:
document.write("ok");
while(x == "10"){
document.write("ok");
}
Maybe I'm being very stupid and missing something obvious out but I don't see the benefit of using do while over my above example.