Learn Advanced Array Methods by Building a Statistics Calculator - Step 4

g-a-statistics-calculator/step-4

I’ve tried about 6 different variations for the task: Create a numbers variable and assign it the value of array.map(). But I still get: You should use the .map() method on your array variable.

WHERE AND WHAT AM I DOING WRONG?

1. Using an anonymous arrow function:

const numbers = array.map((element) => Number(element));

1. Using an explicit return statement with an anonymous arrow function:

const numbers = array.map((element) => {
return Number(element);
});

1. Using the implicit return feature of arrow functions with parentheses around the argument:

const numbers = array.map((element) => (Number(element)));

1. Using the traditional `function` keyword:

const numbers = array.map(function (element) {
return Number(element);
});

1. Using the `Function.prototype.call()` method to invoke the `.map()` method with a defined function:

const numbers = Array.prototype.map.call(array, function (element) {
return Number(element);
});

1. Using a combination of `.bind()` and `.call()` methods to invoke the `.map()` method with a predefined function:

const mapNumbers = function (array) {
return Array.prototype.map.call(array, Number);
}.bind(null, array);

const numbers = mapNumbers();

Welcome to our community!

Post a link to the challenge.

Read the instructions carefully: “Create a `numbers` variable and assign it the value of `array.map()`”.

There are no instructions for adding the `.prototype` or `.call()` method, or `bind()` etc.

``````new_variable = value;
``````

the new_variable is `numbers`,
the value is array.map();

2 Likes

Thank you!
Have a great time!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.