HomeChallengesRepsProblemsLeaderboardTake a challenge

Let the compiler look

orders.js has just become orders.ts with strict on. It has three bugs nobody noticed: a typo that makes the total NaN, an id that arrives as a string and finds nothing, and no types at all. Give the compiler enough to find them, then fix what it finds.

Beginner5 min on the clock5 graded checks · 100 pointsTypes That Catch Bugs
Graded by running your code against real cases.

What you build

  • Annotate findItem’s id as a number and orderTotal’s items
  • Fix the typo the compiler now points at
  • Convert the form value with Number(...) before the call
  • Leave no compile errors and no any

Done means

Compiles clean under strict with no any, the total is right, and the form value is converted at the edge.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. Compiles clean under strict+25TypeScript basics
  2. No any anywhere+20TypeScript basics
  3. orderTotal returns 4,300 on the sample order+20TypeScript basics
  4. The form value is converted before the call+20TypeScript basics
  5. The picked item is Fried plantain+15TypeScript basics

What it teaches

The rest of Types That Catch Bugs