Generation

generate functionThu, 29 Dec 2022

crop text at n length and save croped text in arrays

function crop_text(n, text) { var arr = [] var word = "" for (var i = 0; i < text.length; i++) { if (i%n === 0 && i>0){ arr.push(word) word = "" continue } word += text[i] } arr.push(word) return arr }

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant