function myLogic(){ let minAge = “18”; minAge = Number(minAge); let maxAge = 18; let myAge = prompt(“Input age” + minAge); let vote;
if( minAge === maxAge ){ vote = “You are eligible to vote”; }else{ vote = “Sorry! too young to vote”; }alert(myAge + vote);
How about:
function getVotingAge() { let age = prompt('Input age'); if (age < 18) { alert('Sorry, you are too young to vote') } else { alert ('You are eligible to vote!') } } getVotingAge();
wow! it work am really grateful , but what cause my code not to work.
this, you are comparing two different numbers so the first if statement is never executed