统计字符串中某个字符的个数
生活随笔
收集整理的這篇文章主要介紹了
统计字符串中某个字符的个数
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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>
轉載于:https://www.cnblogs.com/lan-yu/p/9873164.html
總結
以上是生活随笔為你收集整理的统计字符串中某个字符的个数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: javascript之Partial A
- 下一篇: NOIP2018提高组模拟题(六)