JavaScript - 为什么else警报使用if执行

0 javascript alert if-statement

它也发生在PHP中.每当pass1进入提示弹出窗口时,它下方的警报就会像往常一样显示出来.但在那之后,其他警报框也出现了.如何在pass1上停止执行其他警报框?

function download()
{
x=prompt("Enter the download code here.")
if (x=="pass1")
{
alert("This function has been deleted by the administrator. Jeff, get the hell out       of here.")
}
if (x=="pass2")
{
alert("I like pie too.")
}
else
{
alert("The code you specified was invalid.")
}
}
Run Code Online (Sandbox Code Playgroud)