JSFiddle - React, Tailwind, and code Playground
JavaScript
const string = 'stackoverflow';
function spliter(nr) {
const chars = nr.split('');
let temp = [];
let parts = [];
for (let char of chars) {
temp.push(char);
if (temp.length == 3) {
parts.push(temp.join(''));
temp = [];
}
}
if (temp.length) parts.push(temp.join(''));
return parts;
}
console.log(spliter(string));