Add new solution version that directly returns (#34427)

In this case (that is quite typical) more complicated
language features are not necessary.
This commit is contained in:
Mateusz Konieczny
2018-11-22 22:14:40 +01:00
committed by Nathaniel Suchy
parent 346b0a7ce1
commit 271b2c3434

View File

@ -26,3 +26,12 @@ return arr.indexOf(elem) >= 0 ? true : false;
}
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
```
- `Solution-3` demonstrates how the problem can be solved by directly returning result of the comparison.
## Solution-3:
```javascript
function quickCheck(arr, elem) {
return arr.indexOf(elem) != -1;
}
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
```