Files

28 lines
712 B
Markdown
Raw Normal View History

2018-10-12 15:37:13 -04:00
---
title: Use the some Method to Check that Any Elements in an Array Meet a Criteria
---
# Use the some Method to Check that Any Elements in an Array Meet a Criteria
2018-10-12 15:37:13 -04:00
---
## Problem Explanation
2018-10-12 15:37:13 -04:00
Use the some method inside the checkPositive function to check if any element in arr is positive. The `checkPositive` function should return a Boolean value.
#### Relevant Links
2018-10-12 15:37:13 -04:00
- [Array.prototype.some()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
---
## Solutions
<details><summary>Solution 1 (Click to Show/Hide)</summary>
2018-10-12 15:37:13 -04:00
```javascript
function checkPositive(arr) {
return arr.some(elem => elem > 0);
2018-10-12 15:37:13 -04:00
}
checkPositive([1, 2, 3, -4, 5]);
```
</details>