Trying to get all instances of a blank space using indexOf and a for loop and add it to arrofSpacIndex array
function allInstancesOfBlankSpace (words)
{
var j=0;
var arrOfSpaceIndex = [];
//creating an array to store all instances of blank spaces
for(i=0; j = -1; i = pos)
{
var pos = words.indexOf('', i )
//gets integer of next instance of character want it to be separate from j so position of i doesnt get set to -1
var j= words.indexOf('', i )
//checks if there is another instance of the blank space if none then -1 which should stop loop from iterating
arrOfSpaceIndex.push(pos)
//adds position of blank space to array
}
return arrOfSpaceIndex
}
allInstancesOfBlankSpace("HELLO MY FRIEND")