vendredi 13 février 2015

How do I change the value of a property in JavaScript?



var csequence = {
light1: 0,
light2: 0,
light3: 0,
light4: 0
};
var usequence = {
light1: 0,
light2: 0,
light3: 0,
light4: 0
};
var lightUp = function () {
var answer = pickDiv()
if (answer === 1) {
$("#b1c").addClass("lightUp");
window.setTimeout(function () {
$("#b1c").removeClass("lightUp");
}, 500);
csequence.light1 = csequence.light1 + 1;
} else if (answer === 2) {
$("#b2c").addClass("lightUp");
window.setTimeout(function () {
$("#b2c").removeClass("lightUp");
}, 500);
csequence.light2 = csequence.light2 + 1;
} else if (answer === 3) {
$("#b3c").addClass("lightUp");
window.setTimeout(function () {
$("#b3c").removeClass("lightUp");
}, 500);
csequence.light3 = csequence.light3 + 1;
} else {
$("#b4c").addClass("lightUp");
window.setTimeout(function () {
$("#b4c").removeClass("lightUp");
}, 500);
csequence.light4 = csequence.light4 + 1;
};
};


These are two sections of code from a web game I am making. Everything works perfectly except for the fact that the property values are not updated when I run the lightUp function. Why isn't this working?





Aucun commentaire:

Enregistrer un commentaire