'JavaScript var password error

i keep putting in this code, but every time i try it out, it lets me in whether or not it's the right password, rather than only letting me in if it's the right password. Can someone help with this issue?

<script language="JavaScript">
<!--hide
var password;
var pass1="password1";
var pass2="password2";
password=prompt('Enter Password To View The Page',' ')
if (password==pass1||pass2)
alert('Correct password, Welcome.');
else{ 
window.location="http://www.google.com";
}

</script>


Solution 1:[1]

if (password==pass1|| password == pass2){
    alert('Correct password, Welcome.');
}
else{ 
    window.location="http://www.google.com";
}

working example

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 AD.Net