JSFiddle - React, Tailwind, and code Playground
by Qwerty_Wasd
JavaScript
let age = prompt('age?');
let result;
if (age.match(/1[1-4]$/))
result = "лет";
else if (age.endsWith("1"))
result = "год";
else if (age.match(/[2-4]$/))
result = "года";
else
result = "лет";
console.log(`${age} ${result}`);