Pls i want to write a code if a particuler person is eligible for voting the age limit is 18

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);

1 Like

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();
1 Like

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