--- id: 587d7b88367417b2b2512b45 title: Write Higher Order Arrow Functions challengeType: 1 videoUrl: '' localeTitle: Escribir funciones de flecha de orden superior --- ## Description
Es hora de que veamos cuán poderosas son las funciones de flecha al procesar datos. Las funciones de flecha funcionan realmente bien con funciones de orden superior, como map() , filter() y reduce() , que toman otras funciones como argumentos para procesar colecciones de datos. Lee el siguiente código:
FBPosts.filter (función (publicación) {
volver post.thumbnail! == null && post.shares> 100 && post.likes> 500;
})
Hemos escrito esto con filter() para al menos hacerlo de alguna manera legible. Ahora compárelo con el siguiente código que usa la sintaxis de la función de flecha en su lugar:
FBPosts.filter ((post) => post.thumbnail! == null && post.shares> 100 && post.likes> 500)
Este código es más breve y realiza la misma tarea con menos líneas de código.
## Instructions
Use la sintaxis de la función de flecha para calcular el cuadrado de solo los enteros positivos (los números decimales no son enteros) en la matriz realNumberArray y almacene la nueva matriz en la variable squaredIntegers .
## Tests
```yml tests: - text: squaredIntegers debe ser una variable constante (usando const ). testString: 'getUserInput => assert(getUserInput("index").match(/const\s+squaredIntegers/g), "squaredIntegers should be a constant variable (by using const).");' - text: squaredIntegers debe ser una array testString: 'assert(Array.isArray(squaredIntegers), "squaredIntegers should be an array");' - text: 'squaredIntegers deben ser [16, 1764, 36]' testString: 'assert.deepStrictEqual(squaredIntegers, [16, 1764, 36], "squaredIntegers should be [16, 1764, 36]");' - text: function palabra clave de la function no se utilizó. testString: 'getUserInput => assert(!getUserInput("index").match(/function/g), "function keyword was not used.");' - text: bucle no debe ser utilizado testString: 'getUserInput => assert(!getUserInput("index").match(/(for)|(while)/g), "loop should not be used");' - text: 'map , filter o reduce debe ser usado' testString: 'getUserInput => assert(getUserInput("index").match(/map|filter|reduce/g), "map, filter, or reduce should be used");' ```
## Challenge Seed
```js const realNumberArray = [4, 5.6, -9.8, 3.14, 42, 6, 8.34, -2]; const squareList = (arr) => { "use strict"; // change code below this line const squaredIntegers = arr; // change code above this line return squaredIntegers; }; // test your code const squaredIntegers = squareList(realNumberArray); console.log(squaredIntegers); ```
## Solution
```js // solution required ```