Double Time 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()

Hi there, guys! Why there’s always this empty space after the coma? Does it have a specific function? Could you explain it to me, please?

That’s a feature of our key-based code editor, showing that another parameter can be added. It doesn’t mean you should add one, just that you can.

You’ll see similar behavior with arrays and objects, showing that additional items/properties can be added, like this:

let exampleArray = [

let exampleObject = {
    exampleProperty: 'example value',
    ____ : ____
1 Like

Hi! I was trying to solve this puzzle in different ways. For example, I put 2 “" number instead of number "” 2 and it didn’t work… :thinking: (I’m sorry, I could not type the asterixes without turning the words between them into italics).
Could you explain this, please?