在这个例子中,我真的不明白我在做什么错。请参见下面的代码。
<script language = "javascript">
var month = new Array(12);
month [0] = "Enero";
month [1] = "Febrero";
month [2] = "Marzo;";
month [3] = "Abril";
month [4] = "Mayo";
month [5] = "Junio";
month [6] = "Julio";
month [7] = "Agosto";
month [8] = "Septiembre";
month [9] = "Octubre";
month [10] = "Noviembre";
month [11] = "Diciembre";
var i = 0;
do {
month[i] = parseInt(prompt("Type the number of the
month:"));
}
if (month[i]>12) {
document.write("Incorrect month");
}
else {
document.write ("The month is :" +month+ ".");
}
</script>
答案 0 :(得分:0)
我猜你忘记了什么,所以我更改了代码。我希望可以。
<script language = "javascript">
var month = new Array(12);
month [0] = "Enero";
month [1] = "Febrero";
month [2] = "Marzo;";
month [3] = "Abril";
month [4] = "Mayo";
month [5] = "Junio";
month [6] = "Julio";
month [7] = "Agosto";
month [8] = "Septiembre";
month [9] = "Octubre";
month [10] = "Noviembre";
month [11] = "Diciembre";
var i = 0;
do {
let m = parseInt(prompt("Type the number of the month:"));
if (m>12) {
document.write("Incorrect month.</br>");
}
else {
document.write ("The month is :" +month[m]+ ".</br>");
}
i++;
} while(i<12)
</script>