en.javascript.info/1-js/2-first-steps/19-function-basics/2-rewrite-function-question-or/solution.md
Ilya Kantor 3dc3018fd1 works
2016-07-02 18:11:36 +03:00

374 B

Using a question mark operator '?':

function checkAge(age) {
  return (age > 18) ? true : confirm('Did parents allow you?');
}

Using OR || (the shortest variant):

function checkAge(age) {
  return (age > 18) || confirm('Did parents allow you?');
}

Note that the brackets around age > 18 are not required here. They exist for better readabilty.