function getHighscore(game) { return parseInt(localStorage.getItem('hs_' + game) || '0', 10); } function setHighscore(game, score) { if (score > getHighscore(game)) { localStorage.setItem('hs_' + game, score); } }