var location1 = 3;
var location2 = 4;
var location3 = 5;
var quess;
var hits = 0;
var quesses = 0;
var isSunk = false;
while (isSunk == false) {
quess = prompt("Ready, aim, fire! (enter a number 0-6):");
if (quess < 0 || quess > 6 ) {
alert("Please enter a valid cell number");
} else {
quesses = quesses + 1;
if (quess == location1 || quess == location2 || quess == location3) {
alert("HIT!");
hits = hits + 1;
if (hits == 3) {
isSunk == true;
alert("You sank my battleship!");
}
} else {
alert("MISS");
}
}
}
var stats = "You took " + quesses + " guesses to sink the battleship, " + "which means your shoothing accuracy was " + (3/quesses);
alert(stats);