how can I turn my if else to a ternary

javascript

Solution

view_list.style.visibility = (val === true && optval === 'car') ? 'hidden' : 'visible';

In a ternary statement, you have a few different parts:

`var` = `expression` ? `value_if_true` : `value_if_false`

- `var` is optional. You don't have to include it if you don't want to worry about assignment, but in general this is what ternaries are most often used for.

- `expression` is the expression to evaluate. Its boolean evaluation is stored for the next part.

- `value_if_true` is used if `statement` is truthy.

- `value_if_false` is used if `statement` is falsey.

Problem

I can't figure out how to turn my if else statement into a ternary ``` if (val === true && optval === 'car')view_list.style.visibility = 'hidden'; else view_list.style.visibility = 'visible'; ```

Original source