Code Golf · #41 · 2026-05-15
Run-length encode
Difficulty 3/3 · JavaScript
How to play
Write a JavaScript function body that passes all test cases using the fewest characters. Run against examples first, then submit for the full test suite. Eagle < Birdie < Par.
Given a string, run-length encode it: consecutive identical characters become the character followed by its count. e.g. "aaabbc" → "a3b2c1".
Examples
f("aaabbc") → a3b2c1
f("abc") → a1b1c1
Loading your progress...
Your code (function body — receives input)
function(input) { 0 chars
}
Write the shortest JavaScript function body that passes all tests · Back to hub