JavaScript输出数组中有几个字符串中包含“a”或“A”
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
</head>
<body>
<script type="text/javascript">
var arr = new Array('AAee','aadfdfd','sfgfd','aljidn','dcs','scefsd','basktaball');//单引号双引号都可!
var count = 0;
for(var i int arr){
document.write(arr[i]+"<br/>");
if(arr[i].indexOf("a")!=-1||arr[i].indexOf("A")!=-1){
count++;
}
}
document.write("共有"+count+"个字符串中包含a或A!");
</script>
</body>
</html>
别爱我没结果 除非点赞加关注!