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.

Dealing with array ranges

Dealing with array ranges - CoffeeScript Tutorial

From the course: Learning CoffeeScript

Start my 1-month free trial

Dealing with array ranges

In the same way that CoffeeScript adds capabilities to variables, arrays get some super powers with the language, namely something called ranges. So let's take a look. So creating a basic array is pretty simple, we just type in the variable name and then some values, so you could do something like this. You don't have to type in var. And some of the punctuation, you can take some of these and put them on separate lines, and that's going to work just fine. Actually, let me go ahead and put another one in there. So, you can see, sometimes you can't tell, with the conversion, that something's happened, so you have to kind of put in an extra number. You can see the page kind of refresh sometimes, and that's a clue. Now, with arrays, you can also do ranges, so you probably know what I mean by that. So, you can type in something like 1..10, and that gives you ten numbers, including the 1 and the 10. If you want to, you can type in an extra period, and that means don't include this last…

Contents