Created
April 23, 2012 02:32
-
-
Save jomontanari/2468392 to your computer and use it in GitHub Desktop.
Code snippets for ThoughtWorks Team Hug presentation - comparing JavaScript and CoffeeScript (part 2)
This file contains 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 textColor; | |
if (result === "failed") { | |
textColor = "red"; | |
} else if (result === "not run") { | |
textColor = "yellow"; | |
} else { | |
textColor = "green"; | |
} |
This file contains 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
textColor = | |
if result is "failed" | |
"red" | |
else if result is "not run" | |
"yellow" | |
else | |
"green" |
This file contains 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 teamHugPresentationList = [ "CoffeeScript", "Whiskey", "Consulting"]; | |
var whoopsie = function() { | |
teamHugPresentationList = []; | |
return teamHugPresentationList; | |
} |
This file contains 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
teamHugPresentationList = [ "CoffeeScript", "Whiskey", "Consulting"] | |
whoopsie -> | |
teamHugPresentationList = [] | |
teamHugPresentationList |
This file contains 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 TeamHugPresentation = function(title, presenter) { | |
return { | |
getHeadline: function() { | |
return title + " by " + presenter; | |
} | |
} | |
}; | |
var myPresentation = TeamHugPresentation("CoffeeScript", "Jo Cranford"); |
This file contains 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 TeamHugPresentation = function(title, presenter) { | |
this.getHeadline = function() { | |
return title + " by " + presenter; | |
}; | |
}; | |
var myPresentation = new TeamHugPresentation("CoffeeScript", "Jo Cranford"); |
This file contains 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 TeamHugPresentation = function(title, presenter) { | |
this.title = title; | |
this.presenter = presenter; | |
}; | |
TeamHugPresentation.prototype.getHeadline = function() { | |
return this.title + " by " + this.presenter; | |
}; | |
var myPresentation = new TeamHugPresentation("CoffeeScript", "Jo Cranford"); |
This file contains 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
class TeamHugPresentation | |
constructor: (@title, @presenter) -> | |
getHeadline: -> | |
@title + " " + @presenter |
This file contains 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
weatherInCities = | |
(("#{city.name}: #{city.weather}") for city in listOfCities) |
This file contains 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 i, weatherInCities; | |
weatherInCities = []; | |
for(i = 0; i < listOfCities.length; i++) { | |
var city = listOfCities[i]; | |
weatherInCities.push(city.name + ":" + city.weather); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment