Skip to content

Instantly share code, notes, and snippets.

@js2me
Last active October 11, 2017 08:21
Show Gist options
  • Save js2me/6fed406f18017054b9cf0c5af279113b to your computer and use it in GitHub Desktop.
Save js2me/6fed406f18017054b9cf0c5af279113b to your computer and use it in GitHub Desktop.
function declareOfNum(number,tiles = ['го','х','и','а']){
let num = typeof number === 'string' ? +number : number;
let lastNum = num % 10;
return lastNum ? (lastNum > 1 && lastNum < 5 && tiles[1] || lastNum > 4 && tiles[2] || tiles[0]) : lastNum === 0 && tiles[num > 100 ? ((num + '')[1] === '0' ? 3 : 2) : 2] || 'NaN';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment