i am new to javascript. i have paragraph and split them using str.split(‘.’). Also i need to remove quotation marks from string after split method. How to eliminate them?
My mamma stood up and lifted a box off the ground. “We’re in America,
Rune. They speak English here. You’ve been speaking English for as long as
you’ve been speaking Norwegian. It’s time to use it.”
and i want the result like
My mamma stood up and lifted a box off the ground. We’re in America,
Rune. They speak English here. You’ve been speaking English for as long as
you’ve been speaking Norwegian. It’s time to use it.
2
Answers
It would be easier to remove all quotation marks before splitting the array.
If you insist on splitting the array first, you should loop/map over each sentence after you
.split
.As you can see, you end up with an empty string as the last item. To get rid of that you could also use
.filter()
.To get rid of the whitespace, you could also use
.trim()
.So to put all of this together:
You can use .replace(),