<pre name="code" class="html"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>统计包含“a”或“A”的字符串的个数</title>
<script type="text/javascript">
var countryList=["America","Greece","Britain","Canada","China","Egypt"];
var count=0;
document.write("在以下字符中:<br/>");
for(var i in countryList){
document.write(countryList[i]+"<br/>");
if(countryList[i].indexOf("a")!=-1||countryList[i].indexOf("A")!=-1)
count++;
}
document.write("共有"+count+"个字符中串包含a或A。");
</script>
</head>
<body>
</body>
</html>
实现的比较简单,遇到相似的之后举一反三!!!