You need to fill the array with the help of the command prompt in which there will be a list of 5 any names. Then print a prompt with the prompt asking for the username

The entered name, a cycle to compare with the names in the array. If the entered username does not exist in the array, give an error message to alert (). If there is a match - display the message "Andrew, you have successfully entered . "

Instead of "Andrew" should be the name of the current user.

I sketched the code, but it is incomplete and I can not understand the algorithm of actions.

var arr = []; for (var i = 0; i < arr.length; i++); var a = prompt("Enter your name"); if (a == arr) { alert( a + " вы успешно вошли! "); } else{ alert("Ошибка") } 

Closed due to the fact that the issue is too general for participants Dmitriy Simushev , user194374, fori1ton , cy6erGn0m , zRrr Jul 5 '16 at 0:08 .

Please correct the question so that it describes the specific problem with sufficient detail to determine the appropriate answer. Do not ask a few questions at once. See “How to ask a good question?” For clarification. If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

     var arr = ['Андрей','Петр','Алексей'], a = prompt("Enter your name"), i = 0; while (i < arr.length) { if (a == arr[i]) { alert("Ошибка"); return false; } else if(a !== arr[i] && i === (arr.length-1)){ alert( a + " вы успешно вошли! "); arr.push(a); console.log(arr); return false; } i++; } 

    in the console after successful addition you can see that a new user has been added to the array

    • thank you, very grateful! - Taras Dotsenko
    • A little wrong right wrote, corrected)) - Karalahti
    • she just started to learn, the thing is not familiar, but damn interesting) thanks again)) - Taras Dotsenko