我想把這段代碼變成正確的循環語句,以便我可以保存我的重複。我已經盡了最大努力完成它,但我不知道我怎樣才能正確地寫:For循環在JavaScript - 彩票網站
function myProg() {
var luckyNumber = 3;
var luckyNumber2 = 5;
var luckyNumber3 = 8;
var firstInput = document.luckForm.numberBox.value;
var secondInput = document.luckForm.numberBox2.value;
var thirdInput = document.luckForm.numberBox3.value;
var temp = '';
if (firstInput == luckyNumber && secondInput == luckyNumber2 && thirdInput == luckyNumber3 || firstInput == luckyNumber && secondInput == luckyNumber3 && thirdInput == luckyNumber2 || firstInput == luckyNumber2 && secondInput == luckyNumber3 && thirdInput == luckyNumber || firstInput == luckyNumber2 && secondInput == luckyNumber && thirdInput == luckyNumber3 || firstInput == luckyNumber3 && secondInput == luckyNumber && thirdInput == luckyNumber2 || firstInput == luckyNumber3 && secondInput == luckyNumber2 && thirdInput == luckyNumber)
{
alert('Congratulations! You got all 3 numbers correct. You\'ve won £1000!');
}
}
對數字和輸入使用數組而不是單獨的變量。 – Barmar
哦,我不允許使用數組:(我必須使用最基本的JavaScript語句,並找出如何用循環進行總結。 –
如果這是作業作業,我不確定這是哪個地方尋求幫助 - 我也認爲這聽起來像一個非常愚蠢的任務 – Cecchi