I need to get all the words from a sentence and also their index position within the sentence. The same word can happen multiple times in the sentence.
I was trying to do this using the filter method but the index indicates the position in the array not the position within the sentence.
var sentence = "This is a short sentence, a demo sentence."
sentence.split(" ").filter((word, index) => {
}