嗨,我是 Javascript 新手,正在尝试做一个数字检查程序。
客户编号为 12 且在中奖号码范围内。
这似乎工作并打印它是一个中奖号码,但如果我将值更改为 13,它仍然会打印中奖号码。
就像 document.write 正在打印,不管它是否在 if 语句中。
任何帮助或指导将不胜感激
谢谢
这是我的代码
var customerNumbers = 12;
//Array stating the winning numbers
var winningNumbers = [12, 17, 24, 37, 38, 43];
document.write("<h1>This Weeks Winning Numbers are:</h1>");
//For statement to list ALL values in the winning numbers array
for (var i=0;i<winningNumbers.length;i++)
{
document.write(winningNumbers[i] + ",  ");
}
document.write("<h1>The Customer's Number is:</h1>");
document.write(customerNumbers);
//if statement to check if customer number matches with winning numbers
if (customerNumbers == 12 || 17 || 24 || 37 || 38 || 43)
{
document.write("<h3>We have a match and a winner!</h3>");
}
else if (customerNumbers !== 12 || 17 || 24 || 37 || 38 || 43)
{
document.write("<h4>Sorry you are not a winner this week</h4>");
}
else (customerNumbers !== 12 || 17 || 24 || 37 || 38 || 43)
{
document.write("<h4>Sorry you are not a winner this week</h4>");
}