Why is this ternary operator invalid in JS

javascript

Solution

javascript distinguishes between statements and expressions. The ternary operator only handles expressions; throw is a statement.

Problem

``` ​var truth = true; (truth) ? console.log('It is true') : throw new Error('It is not true');​​​​​​​​​​​​​​​ ``` Do ternary operators only accept specific types of objects?

Original source