Created
January 14, 2015 15:52
-
-
Save tybenz/69bb9deea633b0e851c8 to your computer and use it in GitHub Desktop.
Better call-n-times
This file contains hidden or 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
function range(val) { | |
var arr = []; | |
for (var i = 0; i < val; i++) { | |
arr.push(i); | |
} | |
return arr; | |
} | |
function logAndReturn() { | |
console.log('foo'); | |
return 'foo'; | |
} | |
var returns = range(3).map(logAndReturn); | |
assert.equal(returns.length, 3); | |
assert.equal(returns[0], 'foo'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment