This program should display an alert Found it on the 4th iteration
var animals = ["horse", "ox", "cow", "pig", "duck"];
var i = 0;
while (i < animals.length) {
if (animals.slice(i, i + 1) === "pig") {
alert("Found it");
break;
}
i++;
}
Aucun commentaire:
Enregistrer un commentaire