Learn Basic JavaScript by Building a Role Playing Game - Step 16

Tell us what’s happening:

not sure whats wrong the hint says your script element should be out of your head element as fas as i can tell it is

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">

<!-- User Editable Region -->

  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="./styles.css">
    <title>RPG - Dragon Repeller</title>
  </head>
  <body>
    <div id="game">
      <div id="stats">
        <span class="stat">XP: <strong><span id="xpText">0</span></strong></span>
        <span class="stat">Health: <strong><span id="healthText">100</span></strong></span>
        <span class="stat">Gold: <strong><span id="goldText">50</span></strong></span>
      </div>
      <div id="controls">
        <button id="button1">Go to store</button>
        <button id="button2">Go to cave</button>
        <button id="button3">Fight dragon</button>
      </div>
      <div id="monsterStats"></div>
      <div id="text"></div>
    </div <script src="./script.js"></script>>

  </body>

<!-- User Editable Region -->

</html>
/* file: script.js */
let xp = 0;
let health = 100;
let gold = 50;
let currentWeaponIndex = 0;
let fighting;
let monsterHealth;
let inventory = ["stick"];

let button1 = document.querySelector("#button1");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 16

On what I can see of step 16 it doesn’t look like that. The script tags appear in the head element at the start. There must be a glitch if this isn’t how you see it. There is a syntax error on the closing tags of the script element posted above so you must have added that. There’s also a syntax error on the preceding closing div tag.

this is the code as it is right now still having the same error

 <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="./styles.css">
    <title>RPG - Dragon Repeller</title>
  **</head>**
  <body>
    <div id="game">
      <div id="stats">
        <span class="stat">XP: <strong><span id="xpText">0</span></strong></span>
        <span class="stat">Health: <strong><span id="healthText">100</span></strong></span>
        <span class="stat">Gold: <strong><span id="goldText">50</span></strong></span>
      </div>
      <div id="controls">
        <button id="button1">Go to store</button>
        <button id="button2">Go to cave</button>
        <button id="button3">Fight dragon</button>
      </div>
      <div id="monsterStats"></div>
      <div id="text"></div>
     
 **<script src="./script.js"></script>**
  </body>strong text

Hi there @ryanstruckus !

You have deleted the closing div tag of your #game div element. It was there after the #text div element in the challenge editor.

You tagged this wrong
</div <script src="./script.js"></script>>
[/quote]


removed

javascript is fine

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.