Command Palette

Search for a command to run...

Hectal
Phase 13: Cost, Limits and Production
AI Frontend · Exercise 1 of 6Next
Beginner

Count Before Sending

The box #prompt is a textarea. Show the estimated size in #count as N of 20 tokens, using the estimateTokens function that is already written. Show the count at the start too (0 of 20 tokens).

The button #send must be disabled when the box is empty or the estimate is over 20. When it is over, #warn must say Too long by about N tokens. where N is how far over it is. Otherwise #warn is empty.

What Check tests

  1. At the start #count says 0 of 20 tokens and Send is disabled
  2. Typing a short question shows its estimate and enables Send
  3. A long paste shows how far over it is and disables Send

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.