es5-workshop
Version:
NodeSchool ES5 Workshop
46 lines (33 loc) • 921 B
Markdown
A map takes an array and a mapping function and produces a new array containing
the result of applying the mapping function to each value in the
original array, as visualised below:
```
+-+ +--+
|A| |A'|
| | | |
|B| ---> |B'|
| | | |
|C| |C'|
+-+ +--+
```
----
# Task
Convert the following code from a for-loop to Array#map:
```js
function doubleAll(numbers) {
var result = []
for (var i = 0; i < numbers.length; i++) {
result.push(numbers[i] * 2)
}
return result
}
module.exports = doubleAll
```
## Arguments
* numbers: An Array of 1 to 20 Integers between 0 and 9
## Conditions
* Your solution should use Array.prototype.map()
* Do not use any for/while loops or Array.prototype.forEach.
* Do not create any unecessary functions e.g. helpers.
## Resources
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map