2021-02-06 04:42:36 +00:00
---
id: 587d7dab367417b2b2512b6f
2021-03-20 00:31:24 -06:00
title: Usa el método "some" para comprobar si algún elemento en un arreglo cumple un criterio
2021-02-06 04:42:36 +00:00
challengeType: 1
forumTopicId: 301314
dashedName: use-the-some-method-to-check-that-any-elements-in-an-array-meet-a-criteria
---
# --description--
2021-03-20 00:31:24 -06:00
El método `some` funciona con arreglos para comprobar si *algún* elemento pasa una prueba en particular. Devuelve un valor booleano `true` si alguno de los valores cumple el criterio, `false` si no.
2021-02-06 04:42:36 +00:00
2021-03-20 00:31:24 -06:00
Por ejemplo, el siguiente código comprobará si algún elemento en el arreglo `numbers` es menor que 10:
2021-02-06 04:42:36 +00:00
```js
2021-10-27 15:10:57 +00:00
const numbers = [10, 50, 8, 220, 110, 11];
2021-02-06 04:42:36 +00:00
numbers.some(function(currentValue) {
return currentValue < 10 ;
});
```
2021-03-20 00:31:24 -06:00
El método `some` devolverá `true` .
2021-02-06 04:42:36 +00:00
# --instructions--
2021-03-20 00:31:24 -06:00
Utiliza el método `some` dentro de la función `checkPositive` para comprobar si algún elemento en `arr` es positivo. La función debe devolver un valor booleano.
2021-02-06 04:42:36 +00:00
# --hints--
2021-03-20 00:31:24 -06:00
Tu código debe usar el método `some` .
2021-02-06 04:42:36 +00:00
```js
assert(code.match(/\.some/g));
```
2021-03-20 00:31:24 -06:00
`checkPositive([1, 2, 3, -4, 5])` debe devolver `true` .
2021-02-06 04:42:36 +00:00
```js
assert(checkPositive([1, 2, 3, -4, 5]));
```
2021-03-20 00:31:24 -06:00
`checkPositive([1, 2, 3, 4, 5])` debe devolver `true` .
2021-02-06 04:42:36 +00:00
```js
assert(checkPositive([1, 2, 3, 4, 5]));
```
2021-03-20 00:31:24 -06:00
`checkPositive([-1, -2, -3, -4, -5])` debe devolver `false` .
2021-02-06 04:42:36 +00:00
```js
assert(!checkPositive([-1, -2, -3, -4, -5]));
```
# --seed--
## --seed-contents--
```js
function checkPositive(arr) {
// Only change code below this line
// Only change code above this line
}
2021-10-27 15:10:57 +00:00
2021-02-06 04:42:36 +00:00
checkPositive([1, 2, 3, -4, 5]);
```
# --solutions--
```js
function checkPositive(arr) {
return arr.some(elem => elem > 0);
}
```