[ad_1]
You could do it like this:
function splitter(str) {
let splitArr = str.split(' ')
let firstSentence=""
let secondSentence=""
for (const split of splitArr) {
const splitIdx = splitArr.indexOf(split)
if (splitIdx < 3) {
firstSentence += split;
firstSentence += ' '
} else {
secondSentence += split;
secondSentence += ' '
}
}
console.log(firstSentence);
console.log(secondSentence);
}
splitter('Bank of Canada 119 Rue Saint-Jacques, Quebec, QC, H2Y 1L6')I’m working under the assumption that the first three words should be in the first sentence and that the others should be in the second one.
[ad_2]
solved using slice to break a big line into two lines [closed]