How do I convert a JavaScript forEach loop/function to CoffeeScript

use a comprehension

for d, i in flights
  console.log d, i

The code above translates to

var d, i, _i, _len;

for (i = _i = 0, _len = flights.length; _i < _len; i = ++_i) {
  d = flights[i];
  console.log(d, i);
}

so you can see d and i are what you want them to be.

Go here and search for “forEach” for some examples.

Finally, look at the first comment for some more useful info.

Leave a Comment