i am trying to show all the locations the letter 'e' that shows up in a string for my homework.
How do I start?
Here is the question and my attempts. some have been commented out because they did not match what i was looking for in the answer.
i am able to find all the times the letter e appears. Im also able to find the location of the letter 'e' but only the first occurrence of it.
//show the location of each occurence of the character "e" in the string "beg" // *** on one line separated by commas in the span block with id="ans6" // //var begE = beg.match(/e/g) //document.getElementById("ans6").innerHTML=(beg.indexOf('e')) // THIS METHOD COUNTS TOTAL OCCURANCE OF E COULD BE USEFUL IN NUMBER 5 var begE = 0 var positionE = 0 //for (i=0;i//positionE = (beg.indexOf('e') while begE= (beg.indexOf('e') != -1) positionE=begE.toString() document.getElementById("ans6").innerHTML=(begE)