我是初學者,我需要一些幫助來完成我的任務。我無法弄清楚我做錯了什麼。前哨程序不起作用
我必須製作一個程序來讀取一系列值爲0到100和-1的考試分數以停止處理。輸入並驗證分數。程序應計算並打印通過次數(> = 50)和失敗次數(0-50)。當輸入-1分時,顯示通過次數和失敗次數。
<script>
var score = 0;
var passCount = 0;
var failCount = 0;
score = parseInt(prompt("Input score between 1-100, -1 to quit","0"));
while (score !< 0){
if (score >= 50 || score <= 100){
passCount = passCount + 1;
alert ("You passed! Pass count = "+passCount+"Fail count = "+failCount);
}
else
if (score<50){
failCount = failCount + 1;
alert ("You failed! Pass count = "+passCount+"Fail count = "+failCount);
}
else
if (score > 100){
alert ("Invalid number");
}
score = parseInt(prompt("Input score between 1-100, -1 to quit","0"));
}
document.write ("Total: Passes - "+passCount+"Fails "+failCount);
</script>
謝謝!這解決了它。 :-) – 2014-11-25 07:47:31