Could someone help explain why the arguments passed to my displayHitMiss method are not meeting the criteria for a "hit". They are all skipping to "miss" even when they match with a location. I have tried swapping the setAttributes around, which makes it display only "hits", so the problem has to be with my conditional, right?
Cheers,
Rob.
var location1 = "00";
var location2 = "34";
var location3 = "48";
var view = {
//Message area takes a string and displays it
displayMessage: function(msg) {
var messageArea = document.getElementById("messageArea");
messageArea.innerHTML = msg;
},
//Board displays hit
displayHitMiss: function (location) {
var cell = document.getElementById(location);
if (cell == location1 || cell == location2 || cell == location3) {
cell.setAttribute("class", "hit");
} else {
cell.setAttribute("class", "miss");
}
}
};
view.displayMessage("Is this thing on?");
view.displayHitMiss("00");
view.displayHitMiss("46");
view.displayHitMiss("34");
view.displayHitMiss("03");
Aucun commentaire:
Enregistrer un commentaire