From the course: Learning CoffeeScript

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using loops and comprehensions

Using loops and comprehensions - CoffeeScript Tutorial

From the course: Learning CoffeeScript

Start my 1-month free trial

Using loops and comprehensions

In any programming language you have certain constructs that are able to navigate through arrays and objects. In JavaScript there are full of confusing punctuation. CoffeeScript has some really cool ideas on how to do this, so let's take a look. All right, first I'm going to get a list of names. So I'm going to use the same thing that I did before I'll just grab the names from this webpage and I'm going to create a names array with these names. So let's say that we have this array full of names and we need to go through them, so what we can do is use the for statement and assign the elements to a variable that we create here so you can say for thing in names. And then do something with that. So let's go, just go ahead and console log to see this and then you just say thing. Let's save that and we get the names and the console. And that's pretty cool. Look at everything it wrote for us. Now this is what I'm talking about when I say that JavaScript has a ton of punctuation, look at this…

Contents