Exercise Weekend

Goal: In the Assignment, Comparison, and Equality Operators lesson, we learned:

  • The difference between = and ===
  • The assignment operators for each of the mathematical functions: +=, -=, *=, /=
  • Comparison operators, including <, >, <=, and >=
  • Equality operators, including === and !==

Take time to practice using these operators by completing the exercises listed below.

Warm Up

  • What is the difference between a comparison operator and an assignment operator?
  • What is a boolean? What does it represent?
  • How is the += operator different from the + operator?


Assignment & Comparison Practice

Practice assigning and comparing:

  • Set two variables equal to two different numbers. Use a comparison operator to compare these two variables.
  • Change one of their values by using the +=, -=, *=, or /= operator.
  • Then, compare their values again.

If you are working with a pair, switch who's driving and observing and continue with this practice:

  • Try out the <= and >= operators by comparing two numbers.
  • Try out using === equality operator by comparing two strings.
  • Next, use the !== equality operator on two strings or numbers to get a true and false return value.