var STR = 'fdhfgcsaedvcfhgfh' ; var index = str.indexOf ( 'F'); // position of a character appearing var NUM = 0; // the number of characters that appear in the while (! index == -1 ) { the console.log (index); // position of the print string that appears NUM ++; // each occurrence frequency and a plus index = str.indexOf ( 'F',. 1 + index); // start at the next occurrence of the string position continues to look } the console.log ( 'F appeared in a total' + num + 'views');
str.inedxOf ( 'string to look', the starting position);