Developing a program which allows people to enter the office based on there names, this is just a test program to practice and develop my skills in javascript... why does the "try again" statement get executed when there is a successful match between the users input and the my array?
// program to allow people to enter the office
console.log("Welcome to Company X, Please follow the")
let Employees = ["Harry","Dom","j"]
let visitors = prompt("Hi, Enter your name")
let attempts = 0
let alert = 2
for(let i = 0; i<Employees.length;i++) {
while(visitors!=Employees[i] && attempts<alert) {
attempts = attempts + 1
visitors = prompt("try again")
}
if(visitors===Employees[i]) {
console.log("Please move forward")
}
}
if (attempts>=alert) {
console.log("Security ON-ROUTE!")
}