If you're seeing this message, it means we're having trouble loading external resources for Khan Academy.
If you're behind a web filter, please make sure that the domains
*.kastatic.org and *.kasandbox.org are unblocked.
Logic and if Statements
Teach your program to make decisions!
Jessica introduces if statements, a way for your program to decide whether or not to execute a block of code.
Pamela explains how to use mouseIsPressed with if statements to execute code only when the user is pressing their mouse.
Jessica introduces the idea of "booleans", values that can either be true or false.
Pamela shows how to use different logical operators (like && and ||) inside if statements.
Jessica introduces if's soulmate: else.
Jessica shows how to make your conditionals more powerful with "if else".
In the logic challenges, you practiced if and else. Now, use that knowledge to program a magic 8-ball, so you can ask your programs for answers to all your deepest life questions. Change the if() so it checks if the answer variable is a ...