/ * Find the string appeared many times each string * / var str = "ON the depend the If you Life and Death, the I by Will Never give up." // The first step is unified uppercase and lowercase letters var newStr = str .toLocaleLowerCase (); // second step creates an empty object, purpose: as the letter keys, the number of times as the value of var obj = {}; // third obtaining step through each letter string for ( var I = 0; I <newStr.length; I ++ ) { var key = newStr [I]; // for each letter IF (obj [key]) { // is determined that no key has obj // object has the letter of obj [key ] ++ } the else { // The letter no object, then the object is added to the letter, and the letter a number of times to appear, a default obj [Key] =. 1 ; } } // traverse the object, displays the number of each object for ( var Key in obj) { the console.log (Key + "appears the letter" + obj [key] + "views" ); }