1. Build this in Design Mode first
STEP 1Create these elements on screen1 with these exact IDs and starting text.
| Type | ID | Text |
|---|---|---|
| Label | promptLabel | Enter your height in inches: |
| TextInput | heightInput | (leave blank) |
| Button | checkBtn | Check Rides |
| Label | resultLabel | Result: -- |
2. Switch to Code Mode
STEP 2Copy this starter code into Code Mode and fill in the marked STEP.
onEvent("checkBtn", "click", function() {
var height = getNumber("heightInput");
// STEP: write an if / else if / else chain and set resultLabel:
// below 36 -> "Result: Too short for any ride."
// below 48 -> "Result: Kiddie rides only."
// below 60 -> "Result: Most rides, with an adult."
// otherwise -> "Result: All rides allowed."
});
3. Check yourself — predict before you test
STEP 3| Input | What it should test |
|---|---|
| 30 | clearly too short |
| 36 | exactly the first cutoff |
| 40 | clearly kiddie only |
| 48 | exactly the second cutoff |
| 55 | clearly most rides |
| 60 | exactly the third cutoff |
| 72 | clearly all rides |
If 36, 48, or 60 land on the wrong side of their cutoff, that's a boundary bug — recheck the comparison operator on that one line first.
Try it for real before checking the answer key.
Answer key
onEvent("checkBtn", "click", function() {
var height = getNumber("heightInput");
if (height < 36) {
setText("resultLabel", "Result: Too short for any ride.");
} else if (height < 48) {
setText("resultLabel", "Result: Kiddie rides only.");
} else if (height < 60) {
setText("resultLabel", "Result: Most rides, with an adult.");
} else {
setText("resultLabel", "Result: All rides allowed.");
}
});