B
B
BigRussianBoss2018-04-11 17:01:09
JavaScript
BigRussianBoss, 2018-04-11 17:01:09

Function of declension of numerals for the Russian language?

Good day everyone.
The essence of the question is this: you need to write a function for declining numerals, it takes as input:
a number and 3 words, and returns a word! For example -> A, guest, guest, guests - where A is an integer.
I wrote it, but only up to the number 5, how to "finish" the correctness of the output of the word, for any number that is entered?
(I understand that Math.abs() should be used?)
` var getRightName = function (roomsCount) {
var roomsText = roomsCount + 'rooms';
if (roomsCount === 1) {
roomsText += 'a';
} else if ([2, 3, 4].includes(roomsCount)) {
roomsText += 's';
} else if (roomsCount === 5) {
roomsText = roomsText;
}
return roomsText;
};`

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question