Склонение существительных в зависимости от числа
function declination(a, b, c, s) {
var words = [a, b, c];
var index = s % 100;
if (index >=11 && index <= 14) { index = 0; }
else { index = (index %= 10) < 5 ? (index > 2 ? 2 : index): 0; }
return(words[index]);
}