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.
Working with conditional statements - CoffeeScript Tutorial
From the course: Learning CoffeeScript
Working with conditional statements
Conditionals follow the CoffeeScript tradition, of trying to simplify things. A simple if statement looks simpler in CoffeeScript, but it's quite different than the ones we're used to in JavaScript. Let's go ahead and create a very basic if statement in CoffeeScript. We would say something like, if name equals, equals, and then something like my name, then you can do something else, name, equals, and then we'll put in my full name here. So right now we obviously don't have a variable called name, so we'll go ahead and create it and set it to my first name. So let's go ahead and save that and see what it translates to. Now, there's a few interesting things that CoffeeScript just did. We didn't of course need any parentheses, but notice that the double equal sign automatically converted into a triple equal, and that's actually good JavaScript practice. Double equals sign does something called type coercion, which means it tries to make values of different types, like strings and…
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
-
-
-
-
(Locked)
Basic CoffeeScript syntax7m 15s
-
(Locked)
Using realistic assets5m 24s
-
(Locked)
Understanding variables10m 11s
-
(Locked)
Dealing with array ranges4m
-
(Locked)
Working with conditional statements5m 2s
-
(Locked)
Using loops and comprehensions4m 14s
-
(Locked)
Adding basic functions2m 57s
-
(Locked)
Working with splats3m 28s
-
(Locked)
Using the switch statement2m 51s
-
(Locked)
Using aliases for "this" and other tidbits3m 57s
-
(Locked)
-