J
J
Jacob Holus2019-01-22 23:36:09
JavaScript
Jacob Holus, 2019-01-22 23:36:09

Why JS file is not included in HTML?

2 files are on the HDD, one html. another js, before js was normally included in html, when I wrote the path in full, but now, it is not clear why, the scripts have stopped working. As with a tambourine did not dance, all in vain. Already put them in one folder, changed the paths several times - all in vain.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zendor, 2019-01-23
@artemkotok

Firstly, your path to the js file is not correct, and in the error code, I'll fix it now. You forgot quotes in alert . It also turns out that you have an infinite loop after you send a value through prompt.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</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 isShunk = false;
guess = prompt("Input number:");
while (isShunk == false) {
  if (guess > 7) {
    alert("Input normal number!");
  } else {
    guesses = guesses + 1;
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question