I have been given an assignment to check if a given number is an Armstrong number. However, I am facing an issue where the prompt window does not appear when I click the button. This issue only arises when the rest of the function is written out. If the function is standalone, the prompt window functions correctly.
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)
{
document.getElementById("ispis").innerHTML = "number " + num + " is an Armstrong number!";
}
else
{
document.getElementById("ispis").innerHTML = "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)
{
document.getElementById("ispis").innerHTML = "number " + num + " is an Armstrong number!";
}
else
{
document.getElementById("ispis").innerHTML = "number " + num + " is not an Armstrong number!";
}
}
}