How to get rid of repeated numbers in a row?

There is a line. Need to get rid of recurring digits in a row. For example:

"abcd111" -> "abcd1"
"aaaa22122bbbb" -> "aaaa212bbbb"
"a8n64m33xxx000x0" -> "a8n64m3xxx0x0"
April 7th 20 at 11:03
2 answers
April 7th 20 at 11:05
Solution
str.replace(/(\d)\1+/g, '$1')
Thanks for the reply but I can't understand still gives an error
https://repl.it/@MaximusJanukovi/task1-1 - Loy.Wintheiser commented on April 7th 20 at 11:08
@Loy.Wintheiser, that is, you expect me to you skopipastit code will help.

No, it is not. Let alone how to do something. - tito_Doyle commented on April 7th 20 at 11:11
April 7th 20 at 11:07
let out = "";
for (let i = 0, prev = ""; i < str.length; i++) {
 const c = str.charAt(i);
 if (c === prev && c >= "0" && c <= "9") continue;
 out += (prev = c);
}

Find more questions by tags JavaScript