Skip to content

Instantly share code, notes, and snippets.

@MeyCry
Last active August 29, 2015 14:18
Show Gist options
  • Save MeyCry/7e1cc95d5584bbc1d805 to your computer and use it in GitHub Desktop.
Save MeyCry/7e1cc95d5584bbc1d805 to your computer and use it in GitHub Desktop.
helpers js
function truncate(str, maxlength) {
return (str.length > maxlength) ? str.slice(0, maxlength - 1) + '…' : str;
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function getRandomKey(arr) {
return arr[getRandomInt(0, arr.length - 1)];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment