I'm new to Javascript and been trying to find the answer to this for the past few hours. Regardless of whether it's 9 > 1 or 1 > 9, what prints to my HTML is 'true'...and for the second statement, it should be false...
If anyone could point me in the right direction, I'd be appreciative!
var ran1 = parseInt( Math.floor(Math.random() * 10) + 1)
var ran2 = parseInt( Math.floor(Math.random() * 10) + 1)
var ctx = document.getElementById('game').getContext('2d');
ctx.font="2em Verdana";
ctx.fillText(ran1,350,50);
ctx.fillText(ran2,450,50);
document.onkeydown = function (e) {
if (e.keyCode == 39) {
(ran1 > ran2)
if (true) {
ctx.fillText('true', 100, 100);
} else if (false)
ctx.fillText('false', 100, 200);
}
if (e.keyCode == 37) {
(ran2 > ran1)
if (true) {
ctx.fillText('true', 100, 100);
} else if (false)
ctx.fillText('false', 100, 200);
}}
Aucun commentaire:
Enregistrer un commentaire