统计字符串中某个字符的个数

<!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>

以上
posted @ 2019-01-18 20:38  杨超越的秃头姐姐  阅读(380)  评论(0)    收藏  举报