up
This commit is contained in:
parent
83b93e5992
commit
9ad9063d00
742 changed files with 884 additions and 779 deletions
21
1-js/02-first-steps/14-function-basics/3-min/solution.md
Normal file
21
1-js/02-first-steps/14-function-basics/3-min/solution.md
Normal file
|
@ -0,0 +1,21 @@
|
|||
A solution using `if`:
|
||||
|
||||
```js
|
||||
function min(a, b) {
|
||||
if (a < b) {
|
||||
return a;
|
||||
} else {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
A solution with a question mark operator `'?'`:
|
||||
|
||||
```js
|
||||
function min(a, b) {
|
||||
return a < b ? a : b;
|
||||
}
|
||||
```
|
||||
|
||||
P.S. In the case of an equality `a == b` it does not matter what to return.
|
Loading…
Add table
Add a link
Reference in a new issue