I do not have a DB
how can I compare the values taken from the keyboard with those contained in the const?
how can I do to continue in the site only if the input value matches one of those in the const?
this is the JS code:
enter code here
console.log('ciao benvenuto nella console');
var nomeUtente = window.prompt ("Inserisci il tuo User");
const nomi = [Lorenzo, Angelo, David]
console.log(nomi.includes(nomeUtente))
if (nomeUtente == nomi){
alert('Bentornato ' + nomeUtente + ' fai click su ok per entrare nel sito');
}
else {
alert('Nome utente errato')
}
You need to save your user names as strings in the array. Then check if the array includes the user input.
console.log('ciao benvenuto nella console');
var nomeUtente = window.prompt ("Inserisci il tuo User");
const nomi = ['Lorenzo', 'Angelo', 'David']
if (nomi.includes(nomeUtente)){
alert('Bentornato ' + nomeUtente + ' fai click su ok per entrare nel sito');
console.log(false);
}
else {
alert('Nome utente errato')
console.log(true);
}