Created
December 29, 2025 23:55
-
-
Save goofballLogic/4a832d7f65ee063e47ef6660bbb4fa6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const replaceRepeats = (input, number) => | |
| input.replaceAll( | |
| new RegExp(`${number}+`, "g"), | |
| x => x.length); | |
| // test | |
| [ | |
| replaceRepeats('1234500362000440', 0) === "1234523623441", | |
| replaceRepeats('000000000000', 0) == "12", | |
| replaceRepeats('123456789', 1) == "123456789" | |
| ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment