en.javascript.info/1-js/2-first-steps/18-function-basics/2-rewrite-function-question-or/task.md
Ilya Kantor 87bf53d076 update
2014-11-16 01:40:20 +03:00

23 lines
805 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Перепишите функцию, используя оператор '?' или '||'
[importance 4]
Следующая функция возвращает `true`, если параметр `age` больше `18`.
В ином случае она задает вопрос `confirm` и возвращает его результат.
```js
function checkAge(age) {
if (age > 18) {
return true;
} else {
return confirm('Родители разрешили?');
}
}
```
Перепишите функцию, чтобы она делала то же самое, но без `if`, в одну строку.
Сделайте два варианта функции `checkAge`:
<ol>
<li>Используя оператор `'?'`</li>
<li>Используя оператор `||`</li>
</ol>