Stretched Words

Published by Caleb Miller in

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").

Watch a quick demo on how Edabit works.