In this lesson, students will learn more about boolean values. Booleans refer to a value that is either true or false, and are used to test whether a specific condition is true or false.


Students will be able to…

  • Create boolean variables to represent meaningful yes/no values
  • Print out the value of a boolean variable

Logical operators allow us to connect or modify Boolean expressions. Three logical operators are the !, ||, && characters.
* ! = NOT
* || = OR
* && = AND
Logical operators can be used in combination.

With these logical operators, we can construct logical statements such as “I go to sleep when I am tired OR it’s after 9pm”, “I wear flip flops when I am outside AND it is NOT raining”


Students will be able to…
* Describe the meaning and usage of each logical operator: OR (||), AND (&&), and NOT (!)
* Construct logical statements using boolean variables and logical operators

Comparison operators let us compare two values. Using comparison operators in programming is similar to math in that less than <, greater than >, less than or equal to <=, and greater than or equal to >= are the same. The differences are that operators for equal to are == and not equal are !=. Using comparison operators allows our program to make decisions.


Students will be able to…
* Explain the meaning of each of the comparison operators (<, <=, >, >=, ==, !=)
* Create programs using the comparison operators to compare values
* Predict the boolean result of comparing two values
* Print out the boolean result of comparing values

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.


Students will be able to…
* Explain the purpose of if statements
* Create their own if statements to selective choose which code is executed in their programs

For loops in Javascript are written and executed in the same manner as the Karel exercises. However, now we explore in more detail the other parts of the loop besides using it as just a counter. We can modify the initialization statement, test statement, and increment statement. The caterpillar problem is one of the more challenging problems because it has students combine several concepts. You will probably spend a week on for loops.


Students will be able to…
* Create for loops in JavaScript
* Explain the purpose of for loops
* Utilize for loops to avoid typing out repeated code
* Use the loop counter i inside the for loop code to do something different on each iteration

Leave a Reply

Your email address will not be published. Required fields are marked *