#25Arrays - The Must Have
Overview
Practice and refresh the most essential array methods in JavaScript — from map, filter, and reduce to powerful combinations that make data handling in React effortless.
Requirements
- Use only built-in JavaScript array methods (
map,filter,find,some,every,reduce,sort, etc.). - Avoid using traditional
fororwhileloops. - Return new arrays or values instead of mutating the original data.
- Chain multiple methods when necessary to achieve more complex transformations.
- Make sure to handle possible
nullorundefinedvalues safely (e.g., using optional chaining or default values).
Notes
- Each test focuses on a core array method you’ll commonly use when working with data in React components.
- Pay attention to methods that return arrays (
map,filter,sort) versus those that return a single value (find,some,every,reduce). - When sorting or reducing, ensure numeric operations handle missing ages or invalid data gracefully.
- Revisit this challenge periodically — mastering these operations is key to writing concise, expressive React logic.
Tests
- returns array with name and gender
- filters deceased characters
- finds character named 'Lisa'
- filters adult male characters and maps basic info
- maps alive character names
- returns total number of characters
- checks if any character is under 18
- checks if all characters have gender
- sorts characters by ascending age
- sorts character names alphabetically
- calculates average age of alive characters as number with one decimal
- returns phrases that contains 'no' (case insensitive) with character name