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 - CoffeeScript Tutorial
From the course: Learning CoffeeScript
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Basic CoffeeScript syntax7m 15s
-
Using realistic assets5m 24s
-
Understanding variables10m 11s
-
Dealing with array ranges4m
-
Working with conditional statements5m 2s
-
Using loops and comprehensions4m 14s
-
Adding basic functions2m 57s
-
Working with splats3m 28s
-
Using the switch statement2m 51s
-
Using aliases for "this" and other tidbits3m 57s
-
-