1

可能重复:
JavaScript 中的 For 循环 - 彩票网站
代码 javascript 快速解答

var firstInput = document.luckForm.numberBox.value;
var secondInput = document.luckForm.numberBox2.value;
var thirdInput = document.luckForm.numberBox3.value;

for (firstInput = 0; firstInput <= 10; firstInput++) 
{
    if (firstInput = luckyNumber) 
    {
        if (secondInput = luckyNumber2) 
        {
            if (thirdInput = luckyNumber3) 
            {
                alert('Congratulations! You got all 3 numbers correct. You\'ve won £1000!');
            }
        }
    }
}

我试图将此代码(见下文)更改为 for 循环代码(见上文),非常简单,没有数组。我不确定我该怎么做。它应该是彩票,你可以输入三个数字,如果它们是正确的,你会得到你中了 1000 英镑的信息。我用谷歌搜索了很多,但我无法理解 for 循环语句:(

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!');
}
4

0 回答 0