Skip to content

Instantly share code, notes, and snippets.

View tkharuk's full-sized avatar
🐢

Taras Kharuk tkharuk

🐢
View GitHub Profile
@tkharuk
tkharuk / Plural.js
Last active June 6, 2016 19:38 — forked from kjantzer/Plural.js
JavaScript: Plural - create a plural or singluar sentence based on a number
/**
* naive implementation of singular/plural sentence based on count.
* e.g.:
* var str = "Do you want to delete this? There {are|is} [num] book{s} attached."
*
* pluralize(str, 1); // => Do you want to delete this? There is 1 book attached."
* pluralize(str, 2); // => "Do you want to delete this? There are 2 books attached."
*
* @method function
*