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?
- Using an anonymous arrow function:
const numbers = array.map((element) => Number(element));
- Using an explicit return statement with an anonymous arrow function:
const numbers = array.map((element) => {
return Number(element);
});
- Using the implicit return feature of arrow functions with parentheses around the argument:
const numbers = array.map((element) => (Number(element)));
- Using the traditional
function
keyword:
const numbers = array.map(function (element) {
return Number(element);
});
- 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);
});
- 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();