Skip to content

Instantly share code, notes, and snippets.

@Shiggiddie
Created October 29, 2014 17:00
Show Gist options
  • Save Shiggiddie/ac3c81bd737ccd28564b to your computer and use it in GitHub Desktop.
Save Shiggiddie/ac3c81bd737ccd28564b to your computer and use it in GitHub Desktop.
// Month Names
var monthName = function() {
var names = ["January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December"];
return {
name: function(number) { return names[number]; },
number: function(name) { return names.indexOf(name); }
};
}();
console.log(monthName.name(2));
// → March
console.log(monthName.number("November"));
// → 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment