← Back to challenges

Stretched Words

JavaScriptHardstringsformattingloops

Instructions

Write a function that takes a string, and returns a new string with any duplicate consecutive letters removed.

Examples

unstretch("ppoeemm") ➞ "poem"

unstretch("wiiiinnnnd") ➞ "wind"

unstretch("ttiiitllleeee") ➞ "title"

unstretch("cccccaaarrrbbonnnnn") ➞ "carbon"

Notes

Final strings won't include words with double letters (e.g. "passing", "lottery").

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: What Type of Triangle?