+ 2
Why use the while loop when we have the for loop?
I am noob
3 Answers
+ 6
Good question.
With continous usage you will notice that "for" is more used when you have a specific amount of times to iterate, A good example is if you want to count from zero to ten.
"While" is more used when something is unknown, like "While this is true, do this", you won't know when that will be valid, it will repeat that process until that becomes valid.
+ 16
for is mainly used to iterate through arrays or repeat code specific amount of times. I personally use while only when values are unknown....
0
Why use for loop when we have while loop? :)