Created
August 29, 2016 11:53
-
-
Save Nicktho/1196f0ab822cc1b452e02be231fc941f to your computer and use it in GitHub Desktop.
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 addToQueue(...people) { | |
var positions = [] | |
for (var i = 0; i < people.length; i++) { | |
positions[i] = function() { | |
return i + 1 | |
} | |
} | |
return positions | |
} | |
var queuePositions = addToQueue('Greg', 'Charlie', 'Anna') | |
console.log(queuePositions[0]()) // 4 | |
console.log(queuePositions[1]()) // 4 | |
console.log(queuePositions[2]()) // 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment