GAME DEV 2026 · JAVASCRIPT FUNDAMENTALS

Term 1 Assignment 07 — Decisions by Innes

Decision statements let a program choose what to do based on a condition. An if statement runs one branch when a condition is true; else handles the other case.

Reference: W3Schools If / Else

Operators: ! means NOT, && means AND, and || means OR.

Example input/output code

let myHour = 20;
if (myHour < 18) {
  let myGreeting = 'Good Day';
}

The condition myHour < 18 is false when myHour is 20, so the code inside the braces does not run.

1. Simple if / else decision

Enter two numbers. The program checks whether the first number is greater than or equal to the second.


Choose the button to run the comparison.
if (myIn01 >= myIn02) {
  // first number is greater than or equal to second
} else {
  // first number is less than second
}

2. Repeat the decision

This second example uses the same inputs and decision, like the original assignment, and writes to a separate output area.

Second decision output appears here.

3. Complex if condition

This keeps the original complex condition: the first number must be different from the second OR the second must be greater than -8, AND the first must be at most 100.

if ((myIn01 != myIn02 || myIn02 > -8) && myIn01 <= 100) {
  // condition is true
} else {
  // condition is false
}
Complex decision output appears here.

Challenge: Grade decision

Build an if / else if / else chain that classifies a numeric score into four ranges. Validate the input first, and test values exactly on each boundary.