I'm coding a game with different GameOver Text according to the score
Here's the code :
<div id="game-over">
<h3><font color="orange">Tu as courus <span id="score"></span> mètres.</font></h3>
<font color="orange"><h1 id="customegotext">oldHeader</h1></font>
<a href="javascript:void(0)" class="button restart">Ressayer ?</a>
</div>
</div>
<script>
var scoretext;
if (score < 45) {
scoretext = "Text1";
} else if (score > 100 ) {
scoretext = "Text2";
} else if (score > 500 ) {
scoretext = "Text3";
} else if (score > 750 ) {
scoretext = "Text4";
} else {
scoretext = "Text5";
}
document.getElementById("customegotext").innerHTML = scoretext;
</script>
The problem is that it always show "text5" whatever the score is.
Thank you for helping
Precision :
-
All of the code is in the index.HTML file
-
The value "score" is defined in a .JS file by this code
// define variables var player, score, stop, ticker;
-
I'm a beginner in coding
Aucun commentaire:
Enregistrer un commentaire