标签:html body dex for list count rip script indexof
<!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>
以上
标签:html body dex for list count rip script indexof
原文地址:https://www.cnblogs.com/hjsn-101ycy/p/10289612.html