JS Battleship not running

Hello,

Could someone please help explain why my battleship game isn’t running.
Thank you in advance.

<!DOCTYPE html>
<html lang="eng">
	<head>
		<title>Battleship</title>
		<meta charset="utf-8">
	</head>
	<body>
		<h1>Play Battleship!</h1>
		<script src="battleship.js"></script>
	</body>
</html>
var location1 = 3;
var location2 = 4;
var location3 = 5;
var guess;
var hits = 0;
var guesses = 0;
var isSunk = false;

//LOOP: while the ship is not sunk
while (isSunk == false) {
	//GET the user's guess
	guess = prompt("Ready, aim, FIRE! (enter a number from 0-6):");
	//COMPARE the user's input to valid input values
	//IF the user's guess is valid
	if (guess < 0 || > 6) {
		//TELL user to enter a valid number
		alert ("Please enter a valid cell number!");
	//ELSE 
	} else {
		//ADD one guess to guesses
		guesses = guesses + 1;
		//IF the user's guess matches the location
		if (guess == location1 || guess == location2 || guess == location3) {
			//ADD one to the number of hits
			alert("HIT!");
			hits = hits + 1;
			//IF the number of hits is 3
			if (hits == 3) {
				//SET isSunk to true
				isSunk = true;
				//TELL user "You sank my battleship!"
				alert ("You sank my battleship!");
			//END IF
			} else {
				alert("MISS!");
			}
		//END IFF
		}
	//END ELSE
	}
//END LOOP
}
//TELL user stats
var stats = "You took " + guesses + "guesses to sink the battleship, " + 
			"which means your shooting accuracy was " + (3/guesses);
alert (stats);

On line 15 you’ve missed out what you are checking against 6.

  if (guess < 0 || > 6) { 

This should be

if (guess < 0 || guess > 6) {
2 Likes