web-tech/tasks/math-funcs/funcs/pluralizeRecords.js
2025-11-23 14:00:44 +03:00

18 lines
No EOL
552 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function pluralizeRecords(n) {
let recordForm = "записей";
let wasForm = "было найдено";
let lastDigit = n % 10;
let lastTwoDigits = n % 100;
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) {
//pass
} else if (lastDigit === 1) {
recordForm = "запись";
wasForm = "была найдена";
} else if (lastDigit >= 2 && lastDigit <= 4) {
recordForm = "записи";
}
return `В результате выполнения запроса ${wasForm} ${n} ${recordForm}`;
}