Coffeescript:
window.someList = [1, 2, 3, 4, 5] addOne = (item) -> 1 + item window.runThings = () -> addOne item for item in someList
Coffeescript compiled to JavaScript:
(function() { var addOne; window.someList = [1, 2, 3, 4, 5]; addOne = function(item) { return 1 + item; }; window.runThings = function() { var item, _i, _len, _results; _results = []; for (_i = 0, _len = someList.length; _i < _len; _i++) { item = someList[_i]; _results.push(addOne(item)); } return _results; }; }).call(this);
the JS will look less nasty if you give “runThings” a static return value like “true” …Â
The JS is trying to keep track of the results of each add operation to return.