When someone clicks the priceButton button, show the ticket price in the priceLabel label. Kids 12 and under pay $8. People 65 and older pay $9. Everyone else pays $12.
If someone types 65 into the ageInput text box, the label shows $9.
11 strips: C1 to C11
}); C1} else if (age > 65) { C2var age = getNumber("ageInput"); C3} C4price = 9; C5price = 8; C6var price = 12; C7setText("priceLabel", "$" + price); C8if (age <= 12) { C9onEvent("priceButton", "click", function() { C10} else if (age >= 65) { C11Order: C10, C3, C7, C9, C6, C11, C5, C4, C8, C1. Extra: C2
Lines with the same mark can go in either order.
onEvent("priceButton", "click", function() {
var age = getNumber("ageInput");
var price = 12;
if (age <= 12) {
price = 8;
} else if (age >= 65) {
price = 9;
}
setText("priceLabel", "$" + price);
}); Extra strip: } else if (age > 65) {. With > 65, someone who is exactly 65 is not counted, so they pay $12.