Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

split a string every n characters javascript

let chunks = [];

for (let i = 0, charsLength = str.length; i < charsLength; i += 3) {
    chunks.push(str.substring(i, i + 3));
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #split #string #characters #javascript
ADD COMMENT
Topic
Name
4+6 =