Case 1: Find the character 'o' to appear and the number of function Find (STR) { var index = str.indexOf ( 'o'); var NUM = 0; the while (index == -1!) { The console.log ( index); // position NUM ++; index = str.indexOf ( 'O', + index. 1); } the console.log (NUM); // number } Find ( 'abcoefoxyozzopp'); case 2: an array of de-duplication function qc (ARR) { var newArr = []; // Create a new array for (var I = 0; I <arr.length; I ++) { IF (newArr.indexOf (ARR [I]) == -1) { newArr .push (arr [i]); // Add a new query is less than the value of the array } } return newArr; } the console.log (QC ([. 1,. 3,. 5,. 1,. 5, 2])); //. 1 , 3,5,2