Last active
September 2, 2020 14:48
-
-
Save vadimbogomazov/0b3780160cb98b66e6187e5829f9636d to your computer and use it in GitHub Desktop.
Get declination of number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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