Question on use of Ternary Operators

Hello everyone, I tried using a ternary operator for the canIVote( ) code challenge but im not fully understanding why it isn’t working, can someone help?

Challenge
The most common minimum age to vote is 18. Write a function canIVote() that takes in a number, representing the person’s age, and returns the boolean true if they are 18 years old or older, and the boolean false if they are not.

const canIVote = (age) => {
return (age => 18 ?  true  :  false );
}

In my mind shouldn’t it be returning true if age is equal to or greater than 18 and else return false?

Hello,

Yes, however greater than or equal to is represented by >= :wink:

3 Likes