Last active
December 1, 2016 22:55
-
-
Save quieterkali/1935eb54f219b0db703d94ed7f99aa43 to your computer and use it in GitHub Desktop.
map
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
module.exports = CodeMachine = function (coffee) { | |
if (coffee instanceof Coffee) { | |
throw new TypeError('CodeMachine needs coffee to work') | |
} | |
var linesOfCode = [] | |
for (var i = 0, end = Math.random() * 1000; i < end; i++) { | |
var line = [] | |
for (var j = 0; j < 5; j++) { | |
line.push(Math.random() * 78 + 48) | |
} | |
linesOfCode.push(line) | |
} | |
return linesOfCode.map(l => l.map(String.fromCharCode)).join('\n'); | |
} | |
l = [1, 2, 3] | |
var isEven = x => x % 2 === 0 | |
var evenNumbers = l.filter(isEven) | |
console.log(evenNumbers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment