Challenge 1 of 9
Double with map
Instructions
Use `map` to create `doubled` from `nums` with each value times 2.
Editor
IntelliSense on
const nums = [1, 2, 3]; // Write your code below
Module 1 of 4
map, filter, find, reduce, some, every, sort, and flat.
Intermediate JavaScript · 0/9 completed · scroll down for every challenge
Challenge 1 of 9
Use `map` to create `doubled` from `nums` with each value times 2.
Editor
IntelliSense on
const nums = [1, 2, 3]; // Write your code below
Challenge 2 of 9 · Filter evens
Challenge 2 of 9
Use `filter` to keep only even numbers in `evens`.
Editor
IntelliSense on
const nums = [1, 2, 3, 4, 5, 6]; // Write your code below
Challenge 3 of 9 · Find first match
Challenge 3 of 9
Use `find` to get the first number greater than 10 from `nums` into `big`.
Editor
IntelliSense on
const nums = [3, 8, 12, 20]; // Write your code below
Challenge 4 of 9 · Sum with reduce
Challenge 4 of 9
Use `reduce` to sum `nums` into `total`.
Editor
IntelliSense on
const nums = [5, 10, 15]; // Write your code below
Challenge 5 of 9 · Some positive
Challenge 5 of 9
Set `hasNegative` with `some` if any number in `nums` is below 0.
Editor
IntelliSense on
const nums = [3, -1, 8]; // Write your code below
Challenge 6 of 9 · Every adult
Challenge 6 of 9
Set `allAdults` with `every` if every age in `ages` is >= 18.
Editor
IntelliSense on
const ages = [21, 18, 30]; // Write your code below
Challenge 7 of 9 · Sort numbers
Challenge 7 of 9
Sort `nums` ascending into `ordered` without mutating `nums`.
Editor
IntelliSense on
const nums = [3, 1, 2]; // Write your code below
Challenge 8 of 9 · Flatten one level
Challenge 8 of 9
Flatten `nested` one level into `flat` using `flat()`.
Editor
IntelliSense on
const nested = [1, [2, 3], 4]; // Write your code below
Challenge 9 of 9 · Find index
Challenge 9 of 9
Store the index of the first `"done"` in `steps` using `findIndex`.
Editor
IntelliSense on
const steps = ["wait", "done", "ship"]; // Write your code below
Next module