我想计算特定汽车的数量并输出汽车,我可以计算萨博的数量,但是当我尝试排除 2 辆萨博汽车时,我得到“sa”
更新
<!DOCTYPE html>
<html>
<body>
<script>
cars=["BMW","Volvo","Saab","Ford","Saab"];
var count=0;
var totalSuccessArray= new Array();
for (var i=0;i<cars.length;i++)
{
document.write(cars[i] + "<br>");
if(cars[i]=="Saab") {
totalSuccessArray.push(cars[i]);
count++;
}
}
alert(count);
document.write(count + "<br>");
for (var a=0;a<count;a++) {
document.write("totalssuccess"+totalSuccessArray[a] + "<br>");
}
</body>
</html>