const genAvatar = (name) => { let hash = 0; if (name.length === 0) return hash; // Probs don't need to hash using the whole string for (let i = 0; i < name.length; i += 1) { const chr = name.charCodeAt(i); hash = ((hash << 5) - hash) + chr; hash = hash & 19; // We have avatars named 0-19 } return `sprite${hash}`; }; module.exports = genAvatar;