DEV Community

Supaluck Singjan
Supaluck Singjan

Posted on

1 1

Ternary Operator in JS

Ternary operator is a short-hand form in term of condition.

For example,


const score = 80;

if(score >= 80) {
console.log("Passed this step.");
} else {
console.log("Do it again.");
}

Enter fullscreen mode Exit fullscreen mode

But re-write in term of the ternary operator.


score >= 80 ? console.log("Passed this step."): console.log("Do it again.");
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
n9nyz profile image
เกมส์ออนไลน์ บนมือถือ

ติดต่อได้ที่ไหน

Collapse
 
supaluckn profile image
Supaluck Singjan

สวัสดีค่ะ ยังสนใจที่จะติดต่ออยู่ไหมคะ

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay