Last active
April 13, 2022 21:41
-
-
Save vladanyes/550d728cd0953cfc719e31bc28312877 to your computer and use it in GitHub Desktop.
js день дня дней
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
const lastDigitToWord = (digit) => { | |
const lastFigure = parseInt(digit.toString().substr(digit.toString().length - 1, 1)); | |
if (digit >= 11 && digit < 15) { | |
return 'Дней'; | |
} | |
else { | |
if (lastFigure == 1) return 'День'; | |
if (lastFigure > 1 && lastFigure < 5) return 'Дня'; | |
if (lastFigure == 0 || lastFigure >= 5) return 'Дней'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment