如何使循环彩票声明工作?

时间:2012-10-26 23:50:11

标签: loops

  

可能重复:
  For Loop in JavaScript - Lottery Website
  code javascript quick answer

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磅的消息。我已经google了很多但我无法理解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!');
}

0 个答案:

没有答案