Can't understand why JavaScript doesn't run in Chrome

Here is my HTML file. I put inside code in between (I’m learning JS from a book, so example is from there). Initially I added code using <script src=… When I run HTML file JS doesn’t work. It shows only h1 (Play Battleship!) . I’ve already checked, js is allowed in Chrome and code is valid. What is the problem? Thanks in advance

<!DOCTYPE html>
<html lang="en">
	<meta charset="utf-8">
	<script type="text/javascript">
		var location1 = 3;
var location2 = 4;
var location3 = 5;
var guess;
var hits = 0;
var guesses = 0;
var isSunk = false;

while (isSunk==false) {
	guess=promt("Ready, aim, fire! (enter a number from 0-6):");
	if (guess<0 || guess>6) {
		alert("Please enter a valid cell numeber!");
	} else {

	if (guess==location1||guess==location2||guess==location3) {
		if (hits==3) {
			alert("You sank my battleship!");
		} else {
var stats="You took " + guesses + " guesses to sink the battleship, " + 
"which means your shooting accuracy was " + (3/guesses);
	<h1>Play Battleship!</h1>
	<!--<script src="battleship.js"></script>-->


It looks like you just made a simple spelling error.


//should be 

guess = prompt()

also it might be worth spacing some stuff out, like your equal signs just to make it easier to read.

else missing a closing bracket.

It looks like there is a few missing or misplaced brackets as @Cowwy has suggested.

Thank you. It made me almost crazy…)))

1 Like

Thanks to everybody for help!