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) {Hemos escrito esto con
volver post.thumbnail! == null && post.shares> 100 && post.likes> 500;
})
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.
realNumberArray y almacene la nueva matriz en la variable squaredIntegers . 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");'
```