zeero
zeero

Reputation: 3

Can you assign mutiple values to this? and if so, how?

I'm trying to code a password variable that can hold multiple values so any of the following passwords can work and give access to the site.

var pass1="testpass1", "testpass2";

password=prompt('Whats the pass?',' ');

if (password==pass1)
  alert('ja');
else
   {
    alert('nein')
    window.location="https://google.com/";
}

I really need to figure this out.

Thank you!

Upvotes: 0

Views: 53

Answers (1)

Lennert
Lennert

Reputation: 94

You could make pass1 an array and then use the .includes method like so:

let pass1=["testpass1", "testpass2"];

password=prompt('Whats the pass?');

if (pass1.includes(password)){
  alert('ja');
}
else{
    alert('nein')
    window.location="https://google.com/";
}

Upvotes: 2

Related Questions