Created
June 21, 2019 13:44
-
-
Save h09shais/09b73ee3da885565de45f83a4a4739e5 to your computer and use it in GitHub Desktop.
JavaScript map fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[1, 2, 3].map(x => x + 1) | |
> (3) [2, 3, 4] | |
const add = (x) => x + 1; | |
const substract = (x) => x - 1; | |
function mapArray(values, func) { return values.map(func); } | |
mapArray([1, 2, 3], add) | |
> (3) [2, 3, 4] | |
mapArray([1, 2, 3], substract) | |
> (3) [0, 1, 2] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment