The change line and the trend line with awkward input
Nothing prints Infinity or NaN. A rise in late returns is bad, so its change line is marked bad even though the number went up.
A dashboard is read in a glance, not studied. Put the few numbers that matter first, give each one a comparison and a trend, lay the rest out on a grid, and stop adding charts when each question already has one.
Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.
Ready for more? This phase has 5 hands-on exercises with automatic checks.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Write tileText(label, now, before) that returns "label: now (up X% vs before)", using describeChange. What does it print for ("Rides", 100, 0)?
A tile shows the busiest station. Which comparison would you give it, and what would you show when the busiest station changed since last week?
Explain it without notes
Why does a KPI tile show a comparison and not only a number?
Why does the change helper return null instead of a number in some cases?
Why must a change line use words and arrows as well as colour?
How do you decide whether a chart belongs on the first screen?
Preview
Console
Nothing logged yet.Expected console output
normal rise -> up 14.5% vs last week
fall -> down 10.0% vs last week
no change -> no change vs last week
before is 0 -> no earlier value to compare with
before is missing -> no earlier value to compare with
now is NaN -> no earlier value to compare with
tiny base -> up 150.0% vs last week
tiles with a sparkline: all equal, a gap, only falls, late returns
change colours: bad, bad