Making decisions with if
Programs make choices. if runs a block of code only when a condition is true, and else runs when it's false.
Conditions compare values: === (equal), !== (not equal), >, <, >= and <=. Use three equals signs to compare; a single = stores a value.
Chain choices with else if. JavaScript checks each condition from the top and runs the first one that's true.
Example
let temperature = 31;
if (temperature > 30) {
console.log("Hot day: drink water");
} else if (temperature > 15) {
console.log("Nice weather");
} else {
console.log("Take a jacket");
}
Check the biggest value first. If you test
score >= 50 before score >= 90, a 95 would stop at the 50 check.Your tasks
0 of 3 done- result(40) returns "pass"Expected "pass", got undefined
- result(39) returns "fail"Expected "fail", got undefined
- grade gives A, B, C and D at the right scoresExpected "AABBCCD", got ""
Tutor
The tutor guides you toward the answer instead of handing it over. It uses your own Claude usage.
Quick check
What is the difference between = and === ?
undefined undefined
No problems found. Unclosed tags, missing semicolons and errors show up here in plain words.