Skip to content

Instantly share code, notes, and snippets.

@zerc zerc/plural.js
Last active Dec 18, 2015

Embed
What would you like to do?
var plural = function(number, one, two, five) {
var n = Math.abs(number);
n %= 100;
if (n >= 5 && n <= 20) return number + ' ' + five;
n %= 10;
if (n == 1) return number + ' ' + one;
if (n >= 2 && n <= 4) return number + ' ' + two;
return number + ' ' + five;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.