码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-10-29 21:32:55      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:分享   技术   doctype   span   div   bubuko   write   doc   round   

 1 <!DOCTYPE html>
 2 <html>
 3 <body>
 4     <title>统计字符串中某个字符的个数</title>
 5     <script>
 6         var countryList=["one","two","three","four","five","six"];
 7         var count=0;
 8         document.write("在以下字符中:<br/>");
 9         for(var i in countryList){
10             document.write(countryList[i]+" ");
11             if(countryList[i].indexOf("o")!=-1)
12             count++;
13         }
14     document.write("<br/> 字符o有"+count+"个。");
15     </script>
16 </body>
17 </html>

技术分享图片

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

标签:分享   技术   doctype   span   div   bubuko   write   doc   round   

原文地址:https://www.cnblogs.com/lan-yu/p/9873164.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!