Values, Types, and Expressions
Operators
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
astarts at7.bis3.sum = a + bbecomes10.remainder = a % bbecomes1.isBigbecomestrue, so the program printssum=10,remainder=1, andisBig=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.