The following is an example question taken from the Hack Reactor blog (the original source link is below):

(1) Create an array of numbers and save the array to a variable
(2) Iterate through the array using a loop
(3) Create a function that will multiply each number in the array by two
(4) Pass each number in the array to this function
(5) Save the original numbers and the doubled results as key-value pairs in an object

Sources

Code for step 1

In JavaScript, an array is basically a list that stores any number of things, in this case our array will store a list of numbers.
We will store our array in the arr variable.

// create an array of arbitrary numbers and store the
// array in the variable arr
var arr = [1, 2, 5, 7, 10];
// now we can access each number in the array
arr[0]; // will return 1
arr[1]; // will return 2
arr[4]; // will return 10

Code for step 2

This part of the question is asking you to simply iterate through the whole array. We'll create a for loop that will access each number in the array, but we don't do anything with these numbers yet.

Code for step 4

Now we can actually do something with the numbers when we use the for loop. We'll call the doubling function on each number in the array. We're not actually storing the result anywhere though, the code below simply calls the function on each number in the array.

for (var i = 0; i < arr.length; i++) {
doubling(arr[i]);
}

Code for step 5

The last step is to store each number along with its double in an object. An object is a container for elements that are accessed by a key and value. In our case, the key will be the original number and the value will be the doubled value we get from calling the doubling function.

// create an empty object
var obj = {};
for (var i = 0; i < arr.length; i++) {
// the key will be the original number
// (we convert the number to a string because keys in JavaScript cannot be numbers)
var key = arr[i].toString();
// the value will be the doubled number
var value = doubling(arr[i]);
// store the key, value pair in the object
// e.g. {"5": 10}
// e.g. {"5": 10, "6": 12}
obj[key] = value;
}

Final code

Below is the code with all the steps put together. Press the run code button to see the result, and you can also change the array values in the code.

It is not necessary to convert arr[i] to a string in the above code. While it is true that keys must be strings, the object's bracket notation will automatically convert any number between the brackets into a string version of that number. So we can delete the line: