DEV Community

Discussion on: Make Your Javascript Code Cleaner - Ternary Operator

Collapse
 
tbhaxor profile image
Gurkirat Singh • Edited

That isAdult code can be written like this even w/o ternary operator

const age = 18;
const isAdult = age >= 18;
console.log(isAdult); // true
Enter fullscreen mode Exit fullscreen mode
Collapse
 
scottandrews98 profile image
Scott Andrews

Very good point, ternary operator great if you need a specified else other than booleans