Please enable JavaScript to use CodeHS

Intro to Programming with Karel and micro:bit

Description
  • A condition is a function that returns a true/false answer.
  • JavaScript uses if statements as a way to make decisions and execute specific code. If statements are helpful in writing code that can be used in different situations.
Objective

Students will be able to…
* Use conditions to gather information about Karel’s world (is the front clear, is Karel facing north, etc)
* Create if statements to only execute code if a certain condition is true

Description

In this lesson we take a look at more conditional statements, more specifically if/else statements. If/else statements let us do one thing if a condition is true, and something else otherwise.

We write if/else statements like this:

if(frontIsClear()) {
    // code to execute if front is clear
} else {
    // code to execute otherwise
}
Objective

Students will be able to…
* Explain the purpose of an If/Else statement
* Create If/Else statements to solve new types of problems
* Identify when an If/Else statement is appropriate to be used

Description

This lesson is more practice with if statements and if / else statements.

In this lesson we take a look at more conditional statements, more specifically if/else statements. If/else statements let us do one thing if a condition is true, and something else otherwise.

We write if/else statements like this:

if(frontIsClear()) {
    // code to execute if front is clear
} else {
    // code to execute otherwise
}
Objective

Students will be able to…
* Explain the purpose of an If/Else statement
* Create If/Else statements to solve new types of problems
* Identify when an If/Else statement is appropriate to be used