Making Decisions
7 min · TypeScript
Run different code depending on whether something is true.
Enemy 1 of 5
An if runs its { } block only when the condition evaluates to true; else covers everything else, so exactly one of the two blocks runs. Compare values with > , < , >= , <= , and === (strict equality, checking both value and type).
TypeScript, like modern JavaScript, favors === over == for comparisons — === never tries to convert one type to another to force a match, so the result is always predictable. Because temperature here is explicitly typed as number, TypeScript also guarantees you can never accidentally compare it against something incompatible without at least being warned.
Stuck? Ask Rena
Your AI tutor that gives assistance.
Asking Rena in lessons is on Ultimate.