CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #42

Chained Ternary Operators

mediumIf Statements

📄 Code

Read carefully — what does this print?
1let x = 8;
2let label = x % 2 === 0 ? "even" : "odd";
3let sign = x > 0 ? "pos" : x < 0 ? "neg" : "zero";
4console.log(label + " " + sign);

🎯 Your Answer