jeudi 27 mai 2021

How do I make this code work as though the else statement is inexistent when an if is correct, and equally do the same for the else statement

let all = ['Nkechi', 'Añuli', 'Nneka'];

function start(){
  let begin = prompt('Name');
  let counted = "";
  for(let i = 0; i<all.length; i++){
    if(begin === all[i]){
      counted = all[i];
      alert(`Welcome ${counted}`);
    } else {
      alert('Entrance denied');
    }
  }
}

Aucun commentaire:

Enregistrer un commentaire