Download presentation
Presentation is loading. Please wait.
1
If-Statements and If/Else Statements
Using Conditionals to make decisions
2
REVIEW OF LOOPS! What is the best way for Karel to move 10 times?
move(); move(); move(); move(); move(); move(); move(); move(); move(); move(); B. for (var i = 0; i < 10; i++) { move(); } C. move(10); D. move10();
3
What does this For loop mean?
for (var i = 0; i < 10; i++) { move(); } “Var i” refers to everything inside the curly brackets, so when it says “i <10; I++” it is actually saying that it will call “var i”, add one number to it, and then follow the loop again UNTIL it is equal to or greater than 10.
5
When to use If-Statements
If statements have a specific purpose, just like functions and loops. Statements help the computer prevent errors by calculating a decision based on the rules it has created. When would we use something called an “If/Else-Statement”?
6
If/Else Statements If/Else statements are used when you need the computer to make more complex responses to decisions, meaning that it is dealing with multiple true or false problems
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.