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

hi
i am unable to get an output with this code
pls suggest where im going wrong
T.I.A

Your code so far

<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="./styles.css">
    <title>RPG - Dragon Repeller</title>
    <script src="./script.js"></script>
  </head>

<!-- User Editable Region -->

  <body>
    <div id="game">
    <div id="stats">
    <div id="controls">
    <div id="monsterStats">
    <div id="text">
    </div>
    </div>
    </div>
    </div>
    </div>
  </body>

<!-- User Editable Region -->

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

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

Hi! Close tags to avoid errors: <div id="..."></div>

Hi, I did it in the same order.
yet it says its incorrect

<body>
    <div>
    <div id="game">
    <div id="stats">
     <div id="controls">
     <div id="monsterStats">
     <div id="text">
</div>
</div>
</div>
</div>
</div>
  </body>

Yes, I’ve updated my answer, the order is correct

it still isnt giving the output

Show your edited code, pls

Your each div closing tag should be placed immediately after his opening tag.
@kv2

1 Like

This has nothing to do with Step# 15

JavaScript interacts with the HTML using the Document Object Model, or DOM. The DOM is a tree of objects that represents the HTML. You can access the HTML using the document object, which represents your entire HTML document.

One method for finding specific elements in your HTML is using the querySelector() method. The querySelector() method takes a CSS selector as an argument and returns the first element that matches that selector. For example, to find the <h1> element in your HTML, you would write:

Ex: ```
let h1 = document.querySelector(“h1”);

the step changed since

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.