--- id: 587d7dab367417b2b2512b6f title: Use the some Method to Check that Any Elements in an Array Meet a Criteria challengeType: 1 videoUrl: '' localeTitle: 使用某些方法检查阵列中的任何元素是否符合条件 --- ## Description
some方法适用于数组,以检查是否有任何元素通过了特定的测试。它返回一个布尔值 - 如果任何值满足条件,则返回true否则返回false 。例如,以下代码将检查numbers数组中的任何元素是否小于10:
var number = [10,50,8,220,110,11];
numbers.some(function(currentValue){
return currentValue <10;
});
//返回true
## Instructions
使用checkPositive函数中的some方法检查arr任何元素是否为正数。该函数应返回一个布尔值。
## Tests
```yml tests: - text: 您的代码应该使用some方法。 testString: assert(code.match(/\.some/g)); - text: 'checkPositive([1, 2, 3, -4, 5])应该返回true 。' testString: assert(checkPositive([1, 2, 3, -4, 5])); - text: 'checkPositive([1, 2, 3, 4, 5])应该返回true 。' testString: assert(checkPositive([1, 2, 3, 4, 5])); - text: 'checkPositive([-1, -2, -3, -4, -5])应该返回false 。' testString: assert(!checkPositive([-1, -2, -3, -4, -5])); ```
## Challenge Seed
```js function checkPositive(arr) { // Add your code below this line // Add your code above this line } checkPositive([1, 2, 3, -4, 5]); ```
## Solution
```js // solution required ```