Double Time Puzzle Explainer


Aim of the puzzle:
Use the .map method .map() to double the value of each number in an array and save it to a new array.

Walk through of solution:
The .map() method runs a function using each item in an array as an argument and returns the results to a new array. To use it, attach .map() to the array you want to change. Inside the parentheses, write the arrow function that you want to run on each item in the array.

In the code that you start off with, there is an array, numbers, a variable declaration, doubled, and a for…of loop. The doubled variable declaration is incomplete. In this puzzle, you’ll complete the arrow function inside the .map() by adding a return statement.

To complete the puzzle, add return number * 2 inside the arrow function that is used as an argument to .map(). Now, when the code runs, each item in numbers will go through the arrow function, double in value, and get stored in a new array doubled.

Sample code solution:

let numbers = [1, 2, 3 , 4]

let doubled = number => {
    return number * 2

for (let number of doubled){

Javascript Concepts: Variable, Let, Array, Array Methods, Arrow Function, For…of Loop, console.log(), .map()

listed #2