Skip to content

Instantly share code, notes, and snippets.

@Oikio
Last active June 7, 2016 10:14
Show Gist options
  • Save Oikio/5bcca1f369be791896aefccec5de0fca to your computer and use it in GitHub Desktop.
Save Oikio/5bcca1f369be791896aefccec5de0fca to your computer and use it in GitHub Desktop.
function n2w(n, w) {
n %= 100;
if (n > 19) {
n %= 10;
}
switch (n) {
case 1:
return w[0];
case 2:
case 3:
case 4:
return w[1];
default:
return w[2];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment