Created
June 6, 2020 12:01
-
-
Save blacksheep557/de9f0495222df0e5583047a39104fa49 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
| function splitAndDelimit(string = '', interval = 1, delimiter = '') { | |
| let iterator = 0; | |
| for (let i = 0; i < string.length; i++) { | |
| if (iterator === interval) { | |
| string = string.substring(0, i) + delimiter + string.substring(i, string.length) | |
| iterator = 0; | |
| }else{ | |
| iterator++;} | |
| } | |
| console.log(string) | |
| return string | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment