1. String Turn Hump
Example: Border-bottom-color----> borderBottomColor
var str= "Border-bottom-color"; function Change (str) { var arr=str.split ("-"); for (var i=1;i<arr.length;i++) { arr[i]=arr[i].charat (0). toUpperCase () +arr[i]. SUBSTRING (1); } STR=arr.join (""); return str; } Console.log (Change (str));//borderbottomcolor
2. Find the most frequently occurring characters and times in a string
For example: the most characters in SDDDRTKJSFKASJDDDJ are D, appearing 6 times
varStr= "SDDDRTKJSFKKKASJDDDJ"; varMax=0; var Char; functionSearch (str) {varjson={}; for(vari=0;i<str.length;i++){ if(!Json[str[i]]) {Json[str[i]]=Str[i]; } Else{Json[str[i]]+=Str[i]; } } for(vari=0;i<str.length;i++){ if(json[str[i]].length>max) {Max=json[str[i]].length; Char=Str[i]; }} console.log ("The character with the most occurrences is" +Char+ "," +max+ "occurred")} Search (str);
3. Add thousand characters to the string
JS face Test (ii) (Common algorithm programming)