1
0
Fork 0
mirror of https://github.com/jashkenas/coffeescript.git synced 2022-11-09 12:23:24 -05:00

broken waypoint, but fixed line numbers with the new JS comments

This commit is contained in:
Jeremy Ashkenas 2009-12-23 19:42:18 -05:00
parent 6555473788
commit 60eabf63cf
14 changed files with 730 additions and 344 deletions

View file

@ -3,11 +3,7 @@
if (student.excellent_work) {
return "A+";
} else if (student.okay_stuff) {
return if (student.tried_hard) {
return "B";
} else {
return "B-";
};
return student.tried_hard ? "B" : "B-";
} else {
return "C";
}

View file

@ -0,0 +1,33 @@
(function(){
// Assignment:
var number = 42;
var opposite_day = true;
// Conditions:
if (opposite_day) {
number = -42;
}
// Functions:
var square = function(x) {
return x * x;
};
// Arrays:
var list = [1, 2, 3, 4, 5];
// Objects:
var math = {
root: Math.sqrt,
square: square,
cube: function(x) {
return x * square(x);
}
};
// Array comprehensions:
var cubed_list;
var a = list;
var d = [];
for (var b=0, c=a.length; b<c; b++) {
var num = a[b];
d[b] = math.cube(num);
}
cubed_list = d;
})();

View file

@ -4,9 +4,7 @@
} else if (day === "Wednesday") {
go_to_the_park();
} else if (day === "Saturday") {
if (day === bingo_day) {
go_to_bingo();
};
day === bingo_day ? go_to_bingo() : null;
} else if (day === "Sunday") {
go_to_church();
} else {