游戏高分的目的。使用Javascript

时间:2016-10-07 18:24:25

标签: javascript

in 1st html

function stopTyping(){
clearInterval(timer1);
wordChars = [];
wordArea.textContent = "";
typeArea.textContent = "";
**scoreArea.textContent = "Score: " + score;
if(score >= hs)
{
hs=score; 
localStorage.setItem('hs' , hs); 
}**
startButton.hidden = true;
wordArea.hidden = true;
typeArea.hidden = true;
}

其他html

document.getElementById("Easy1").innerHTML = localStorage.getItem('hs');

这是我目前的代码。我只想让我的高分保持在“其他HTML”中,但每当我低于我的高分时,它会记录下一个... 请帮忙。

由于

1 个答案:

答案 0 :(得分:0)

检查一下:

score = parseInt(score); 
hs = parseInt(localStorage.getItem('hs'));
if(score >= hs) {
  hs = score;
  localStorage.setItem('hs', score);
}