Skip to content

Instantly share code, notes, and snippets.

@frank184
Created April 9, 2019 14:17
Show Gist options
  • Save frank184/cb992e676e3aa85246dbcf1c2aaa3462 to your computer and use it in GitHub Desktop.
Save frank184/cb992e676e3aa85246dbcf1c2aaa3462 to your computer and use it in GitHub Desktop.
ordinal_suffix_of
ordinal_suffix_of = function(i) {
var j, k;
j = i % 10;
k = i % 100;
if (j === 1 && k !== 11) {
return i + 'st';
}
if (j === 2 && k !== 12) {
return i + 'nd';
}
if (j === 3 && k !== 13) {
return i + 'rd';
}
return i + 'th';
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment