← Practice
DOM·easy 10 min 50 XP

Character Counter Logic

Write charsRemaining(text, limit) returning how many characters remain before a max-length limit, never negative.

Examples

  • charsRemaining("hello", 10) → 5
  • charsRemaining("hello world!", 5) → 0

Constraints

  • Keep the required function name so the tests can find it
  • Return a value instead of only logging it
  • Do not mutate inputs unless the challenge asks you to
Character Counter Logic · editor

Code runs in an isolated Web Worker with a 3-second timeout — no DOM access, and it can never hang the page.