<!DOCTYPE html> <html> <body> <title>统计字符串中某个字符的个数</title> <script> var countryList=["one","two","three","four","five","six"]; var count=0; document.write("在如下字符中:<br/>"); for(var i in countryList){ document.write(countryList[i]+" "); if(countryList[i].indexOf("o")!=-1) count++; } document.write("<br/> 字符o有"+count+"个。"); </script> </body> </html> 以上