Created
April 23, 2012 02:55
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| createPoint = (lat, lng) -> | |
| { lat, lng } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createPoint(lat, lng) { | |
| var point = { | |
| lat: lat, | |
| lng: lng | |
| } | |
| return point; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(-> | |
| tip = $ "#coffee-tooltip" | |
| tip.addClass "hidden" unless tip.hasClass "hidden" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| var tip = $("#js-tooltip"); | |
| if (!tip.hasClass("hidden")) { | |
| tip.addClass("hidden"); | |
| } | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myTeamHugSession = | |
| title: "CoffeeScript" | |
| time: | |
| start: "2:30pm" | |
| finish: "3:30pm" | |
| console.log _.keys myTeamHugSession # ["title", "time"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var myTeamHugSession = { | |
| title: "CoffeeScript", | |
| time: { | |
| start: "2:30pm", | |
| finish: "3:30pm" | |
| } | |
| }; | |
| console.log(_.keys(myTeamHugSession)); // ["title", "time"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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