I am writing this script where I want to search a paragraph for every instance of a particular word. I am simply using the indexOf phrase which returns only the index of the first instance? Does anyone know of like a indexOfAll (something like that), or do I need to try and loop this somehow? Any help will be greatly appreciated, Here is what I am working with.
var sentance = “A cubist cubed two cubes and ended up with eight. Was she Cuban?”;
var cube = “cube”;
document.writeln("<p>The word cube is located at index’s of " + sentance.indexOf( cube ) + “</p>” );