实现函数数组

时间:2015-06-16 14:58:40

标签: javascript arrays function

我有一个loto的代码,它允许我们使用循环查找和比较数组中的数字。我需要更新我的程序,以便检查结果的工作完成 通过一个名为checkNumber的函数。此功能应该吸引客户 数字和中奖号码数组作为参数。客户编号 应该从一个名为getCustomerNumber的函数返回。数组 中奖号码应该从一个叫做的函数返回 getWinningNumbers。结果的显示应该由函数完成 叫做displayResult()。整个过程应该由一个功能启动 叫做init。谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

 x = checkNumber(12, 17, 24, 37, 38, 43);

 function checkNumber() {
   for (var i = 0; i < winningNumbers.length && !match ; i++)
  if (winningNumbers[i] == customerNumbers) {
  match = true; 
 }
}

} 函数getWinningNumbers

function displayResult(){

var message="This week Winning numbers are:" + "\n" + "\n" + winningNumbers + "\n" + "\n" + "The customer's Number is:" + "\n" + "\n" + customerNumbers + "\n" + "\n" + "We have a match and a winner!";
alert(message)
} Else
var message="This week Winning numbers are:" + "\n" + "\n" + winningNumbers + "\n" + "\n" + "The customer's Number is:" + "\n" + "\n" + customerNumbers + "\n" + "\n" + "Sorry you are not a winner this week";
alert(message)
}

}