const MAX_CHARS_AT_DELTA = 70; const splitTextIntoTwoLines = (string) => { const tokens = string.split(' '); var i = 1; while (tokens.slice(0, i).reduce((acc, el) => acc + el.length, 1) < MAX_CHARS_AT_DELTA) i++; return `${tokens.slice(0, i).join(' ')}<br />${tokens.slice(i).join(' ')}`; };