โ† All coding problems

Compress a string

MediumStrings

Compress runs of the same character as the character followed by its count, e.g. "aabccc" becomes "a2b1c3". An empty string stays empty.

Function
function solve(s)
Example 1
s = "aabccc"
โ†’ "a2b1c3"

Submit also runs 4 hidden tests, including edge cases.

console.log output is shown below