You can do it by splitting myText
on ". "
and then trimming and adding back the full stop.
var myText = "I like cars. I like pandas. I like blue. I like music."
var sentences = myText.split(". ");
for (var i = 0; i < sentences.length; i++) {
if (i != sentences.length - 1)
sentences[i] = sentences[i].trim() + ".";
}
Splitting the text on ". "
instead of on "."
will mean it will work on sentences like "That costs $10.50."