Skip to content

Instantly share code, notes, and snippets.

@robinpokorny
Last active June 24, 2017 12:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save robinpokorny/3cf91b132a80e1e84d4b2d294745b994 to your computer and use it in GitHub Desktop.
Save robinpokorny/3cf91b132a80e1e84d4b2d294745b994 to your computer and use it in GitHub Desktop.
// A: Simple multiplication
function doubleA(n) {
return n * 2
}
// B: With a variable
var two = 2
function doubleB(n) {
return n * two
}
// C: With a helper function
function getTwo() {
return 2
}
function doubleC(n) {
return n * getTwo()
}
// D: Mapping an array
function doubleD(arr) {
return arr.map(n => n * 2)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment