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
- The first question comes from the model
- The same question with other spacing, case and punctuation comes from the cache
- 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.