dimanche 15 novembre 2020

how am i going to turn this right way. get data from prompt to console using if statement the right way

no matter what I pass in the prompt string or number it's returned as 'welcome to the dashboard' even if I put string instead of a number.

let user = prompt('user name:');
let id = prompt('user id:');

let dev = parseInt(id);


if (typeof user === 'undefined' || dev.length === 0){
  console.error('you miss one of the inputs.');

}else if (typeof user === 'string' && typeof dev === 'number'){
        console.log('welocme on yto your dashboard.');
} else{
  console.log('either user name or ID  is wrong please check again');
}

Aucun commentaire:

Enregistrer un commentaire