#need help w some basic algorithm

1 messages · Page 1 of 1 (latest)

snow bluff
#

i wanna make this for identify the actual political situation for ppl by their age.
but fsr in the 'if(18 > age >= 16)' sentence, isn't working how it should, i wanna say that if the person is between 16-17yo, the vote is optional, but isn't working and idk the reason

var age = 16
if(age <=15){
    console.log('cant vote')
}else{
    if(18 > age >=16 ){
        console.log('optional')
    }else if(age >=60){
        console.log('optional')
    }else{
        console.log('mandatory')}
    }```
#

if i use (18 > age && age >=16) it works, but i dont get why this sentence dont works =/

onyx iron
#

18 > age evaluates to true/false, then the rest of your code becomes true/false >= 16, which is non sensical

snow bluff
#

ah, got it