? Week 5 Day 2 Challenge — Ticket Price Finder
CodeX Academy · Level 1 — App Lab · Lesson 7

Ticket Price Finder (Input only)

Optional extra practice for reading user input. Same skill as tonight's demo (temperature advisor) — a different scenario, on your own. The pricing logic used to continue this same challenge with if/else-if — that part now belongs to the Day 4 Roller Coaster challenge instead. Stop once the echo step works.

1. Build this in Design Mode first

STEP 1

Create these elements on screen1 with these exact IDs and starting text.

TypeIDText
LabelpromptLabelEnter your age:
TextInputageInput(leave blank)
ButtoncheckBtnFind My Price
LabelechoLabelYou typed: --

2. Switch to Code Mode

STEP 2

Copy this starter code into Code Mode and fill in the marked STEP.

onEvent("checkBtn", "click", function() {
  // Read ageInput with getText() and echo the raw value into echoLabel.

});

3. Check yourself — predict before you test

STEP 3
InputWhat it should test
12a normal value echoes back exactly
(empty)unexpected value — what does an empty field echo?
twelveunexpected value — text where you might expect a number

Try it for real before checking the answer key.

Answer key
onEvent("checkBtn", "click", function() {
  var typedValue = getText("ageInput");
  setText("echoLabel", "You typed: " + typedValue);
});