Command Palette

Search for a command to run...

Hectal
Phase 13: Cost, Limits and Production
AI Frontend · Exercise 4 of 6 PreviousNext
Intermediate

Normalise the Question

The page keeps a small cache of answers in a Map. Clicking #ask reads #prompt, makes a key with normalise(question), and either shows the saved answer (#source says cache) or asks the route and saves it (#source says model). #answer shows the text, which ends with the model's call number.

Write normalise so that How long is shipping? and how long is SHIPPING are the same question: trim, lowercase, collapse runs of spaces, and drop a trailing ?, ! or ..

What Check tests

  1. The first question comes from the model
  2. The same question with other spacing, case and punctuation comes from the cache
  3. A different question goes to the model

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.