Combine values with arithmetic, comparison, and logic.

Operators

operators.js
const a = 7;
const b = 3;
const sum = a + b;
const remainder = a % b;
const isBig = a > b && sum > 5;

console.log("sum=" + sum);
console.log("remainder=" + remainder);
console.log("isBig=" + isBig);

Follow the Operators

  1. a starts at 7.
  2. b is 3.
  3. sum = a + b becomes 10.
  4. remainder = a % b becomes 1.
  5. isBig becomes true, so the program prints sum=10, remainder=1, and isBig=true. | a | b | sum | remainder | isBig | | --- | --- | --- | --- | --- | | 4 | 3 | 7 | 1 | true | | 7 | 3 | 10 | 1 | true | | 12 | 3 | 15 | 0 | true |
operators Arithmetic operators compute numbers, `%` gives a remainder, comparisons yield booleans, and `&&` combines boolean conditions.

Exercise: operators.js

Reproduce sum=10 and remainder=1, then use the pinned a values 4 and 12 to predict each row.