Skip to content

Instantly share code, notes, and snippets.

@vadimbogomazov
Last active September 2, 2020 14:48
Show Gist options
  • Save vadimbogomazov/0b3780160cb98b66e6187e5829f9636d to your computer and use it in GitHub Desktop.
Save vadimbogomazov/0b3780160cb98b66e6187e5829f9636d to your computer and use it in GitHub Desktop.
Get declination of number
/**
* Get declination of number
* @param {Number} number – current number
* @param {Array} words – words array
* @return {String}
*/
export const declOfNum = (number, words) => words[(number % 100 > 4 && number % 100 < 20) ? 2 : [2, 0, 1, 1, 1, 2][(number % 10 < 5) ? number % 10 : 5]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment