Download presentation
Presentation is loading. Please wait.
Published byLaurens Frank Bogaert Modified over 5 years ago
1
How to allow the program to know when to stop a loop.
While Loops How to allow the program to know when to stop a loop.
2
REVIEW! Why do we use if statements in JavaScript?
To break out of some block of code To do something only if a condition is true To do something while a condition is true To repeat something for a fixed number of times
3
REVIEW! Why do we use if/else statements in JavaScript?
To repeat something for a fixed number of times To either do something if a condition is true or do something else To break out of some block of code To repeat something while a condition is true
5
When would we use a While loop instead of a For Loop????
While Loops vs For Loop When would we use a While loop instead of a For Loop????
6
While Loop vs For Loop For loops are forcing the computer to loop a certain set of code a specific set of times. It is possible that code can run into an error if that number is too small or too large. A while loop doesn’t place an exact number necessarily, rather has a procedure repeat until something interrupts it. While loops are similar to If statements because they repeat until a certain condition is met.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.