Report a bunch of dragon that you saw.
You saw the following dragons:
- RedSpot
- FireBreath
- SnowedIce
- BlueJay
Let's conver this into an array of dragon first.
["RedSpot", "FireBreath", "SnowedIce", "BlueJay"]
In CoffeeScript this is as simple as:
sky = ["RedSpot", "FireBreath", "SnowedIce", "BlueJay"]
saw = (dragon) -> console.log(dragon);
saw dragon for dragon in sky
Which is translated to JavaScript:
var dragon, i, len, saw, sky;
sky = ["RedSpot", "FireBreath", "SnowedIce", "BlueJay"];
saw = function(dragon) {
return console.log(dragon);
};
for (i = 0, len = sky.length; i < len; i++) {
dragon = sky[i];
saw(dragon);
}
// ---
// generated by coffee-script 1.9.2
Generated code is pretty much the best piece of code, so thank js2.coffee