Skip to content

Instantly share code, notes, and snippets.

@jomontanari
Created April 23, 2012 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jomontanari/2468520 to your computer and use it in GitHub Desktop.
Save jomontanari/2468520 to your computer and use it in GitHub Desktop.
Code snippets for ThoughtWorks Team Hug presentation - comparing JavaScript and CoffeeScript (part 4)
createPoint = (lat, lng) ->
{ lat, lng }
function createPoint(lat, lng) {
var point = {
lat: lat,
lng: lng
}
return point;
}
$(document).ready(->
tip = $ "#coffee-tooltip"
tip.addClass "hidden" unless tip.hasClass "hidden"
)
$(document).ready(function() {
var tip = $("#js-tooltip");
if (!tip.hasClass("hidden")) {
tip.addClass("hidden");
}
});
myTeamHugSession =
title: "CoffeeScript"
time:
start: "2:30pm"
finish: "3:30pm"
console.log _.keys myTeamHugSession # ["title", "time"]
var myTeamHugSession = {
title: "CoffeeScript",
time: {
start: "2:30pm",
finish: "3:30pm"
}
};
console.log(_.keys(myTeamHugSession)); // ["title", "time"]
describe "The Game Object", ->
it "should have a score of 0 if I knock down no skittles", ->
game = new Game()
game.roll(0)
score = game.score()
expect(score).toBe 0
describe("The Game Object", function() {
it("should have a score of 0 if I knock down no skittles", function() {
var game = new Game();
game.roll(0);
var score = game.score();
expect(score).toBe(0);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment