Command Palette

Search for a command to run...

Hectal
Phase 4: Strings, Numbers and Dates
JavaScript · Exercise 2 of 5 PreviousNext
Beginner

An emoji-safe character counter

A profile bio allows 50 characters. The counter below uses text.length, so one thumbs-up with a skin tone counts as 4.

Fix countChars(text) so it counts what a person sees (grapheme clusters). Then, in the input handler, add the class over to #count when the count is above MAX, and remove it otherwise.

What Check tests

  1. countChars("hello") is 5
  2. A thumbs-up with a skin tone counts as 1
  3. A family emoji plus ok counts as 4
  4. Typing updates the counter
  5. Over 50 characters adds the class over

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.