#
ending
function ending(...params): string
Description:
Sets the suffix depending on the numerator.
#
params
params = [
quantity: number = 0,
base: string, // word root
multiple: string, // for 5–9 and 0
alone: string, // for 1
double: string, // for 2, 3 and 4
options?: options = {}
]
#
options
interface options = {
unite?: (quantity, word) => string // Determines how the final row will look like
};
#
Example
const quantity = getRandomValue(0, 1000);
const word = {
full: "Банан",
base: "Банан",
suffixes: ["ов", "", "а"]
}
const output = ending(quantity, word.base, ...word.suffixes);
// "Бананов", "Банан" or "Банана"
#
Real example
return `У вас ${ Util.ending(quantity, "клубник", "", "а", "и") }`;