我有一个作业,我必须查看输入的号码是否是阿姆斯特朗号码,问题是当我单击按钮时提示窗口没有显示,只有在我有其余的情况下才会出现的功能写出来。单独显示时,将显示提示窗口。
y -= (jumpCount ** 2) // 2 * neg
答案 0 :(得分:1)
您在此字符串上输入了错误(将“ =”更改为“ +”):
var StrongNum =(firstNum 3)+(secondNum 3)=(thirdNum ** 3);
您不调用函数
尝试在功能之后添加
armNum();
答案 1 :(得分:0)
您在tnis行= (firstNum**3) + (secondNum**3) = (thirdNum**3);
中使用了'='而不是在'+'和您之间出现了错误
function armNum(){
var num = prompt("Enter a number between 0 and 999!: ");
var firstNum;
var secondNum;
var thirdNum;
if(num < 100 && num > 0)
{
firstNum = num/10;
secondNum = num%10;
var StrongNum = (firstNum**3) + (secondNum**3);
if( num == StrongNum)
{
alert( "nummber " + num + " is an armstrong number!")
}
else
{
alert( "number" + num + "is not an armstrong number!"); }
}
if(num > 99 && num < 1000)
{
firstNum = num/100;
secondNum = (num/10)%10;
thirdNum = num % 10;
var StrongNum = (firstNum**3) + (secondNum**3)+(thirdNum**3);
if( num == StrongNum)
{
alert( "nummber " + num + " is an armstrong number!");
}
else
{
alert("number" + num + "is not an armstrong number!");
}
}
}
<body onload=armNum()>
</body>