Skip to content

Latest commit

 

History

History
13 lines (8 loc) · 555 Bytes

4.24.md

File metadata and controls

13 lines (8 loc) · 555 Bytes

If the operator were left associative, then the expression

grade > 90 ? "high pass"
           : grade < 60 ? "fail" : "pass";

would be evaluated as:

(grade > 90 ? "high pass" : grade < 60) ? "fail" : "pass";

which means:

  • if the grade is greater than 90, then return "high pass", which is not empty string and evaluate to true, then return "fail";
  • else evaluates grade < 60 and takes the result as the condition for the second conditional operator, which means if the grade is less than 60, return "fail", else return "pass".