r/coffeescript • u/xjohnseanx • Nov 14 '14
Passing functions as parameters
Hey I am working through http://eloquentjavascript.net/ and decided to use coffeescript. However, I am having some issues getting a few of the examples to work.
function forEach(array, action) {
for (var i = 0; i < array.length; i++)
action(array[i]);
}
forEach(["Wampeter", "Foma", "Granfalloon"], console.log);
// → Wampeter
// → Foma
// → GranfalloonHow would you write something like this using coffeescript? I already tried http://js2coffee.org/ after not being able to come up with a solution myself
4
Upvotes
View all comments
Show parent comment
2
u/xjohnseanx Nov 14 '14
Yeah that's what I thought at first, but it keeps giving me an
I'm running these tests through Meteor using its CoffeeScript package. Could it somehow not function the same as the official npm CoffeeScript?