Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created July 19, 2009 09:42
Show Gist options
  • Select an option

  • Save whalesalad/149865 to your computer and use it in GitHub Desktop.

Select an option

Save whalesalad/149865 to your computer and use it in GitHub Desktop.
Number.prototype.apnumber = function() {
var numberMap =
[ 'zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine' ];
return (9 >= this) ? numberMap[this] : this;
};
// Examples
var foo = 4;
alert(foo); // 4
alert(foo.apnumber()); // Four
var bar = 45;
alert(bar.apnumber()); // 45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment