Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const split = (str, nmb) => {
return str.split('')
.reduce((arr, rec) => {
console.log(`Arr: ${arr} Rec : ${rec}`)
if (arr[arr.length - 1].length < nmb) {
arr[arr.length - 1] = [...arr[arr.length - 1], rec]
return arr
}
return [...arr, [rec]]
}, [[]])
.map(el => el.join(''))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment