Skip to content

Instantly share code, notes, and snippets.

@zykadelic
Last active December 12, 2015 07:39
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 zykadelic/4738570 to your computer and use it in GitHub Desktop.
Save zykadelic/4738570 to your computer and use it in GitHub Desktop.
Easily pluralize strings. Inspired by the Ruby on Rails helper (http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-pluralize).
function pluralize(count, singular, plural){
return (count || 0) + ' ' + (count == 1 ? singular : (plural || singular + 's'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment