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

You should use Math.floor() to round the result of the monster’s level times 6.7 .

function defeatMonster() {
gold += Math.floor(monster.level * 6.7);
}

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge Information:

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

1 Like

we need to see your code in order to help you

please post your code for us and let us know what you need help with

thanks

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like
function defeatMonster() {
    gold += Math.floor(monster.level * 6.7);
}.    

The above mentioned is my code.

1 Like

Your issue is here

There is nothing in your code defined as monster

Double check the correct spelling for the array here

const monsters = [
  {
    name: "slime",
    level: 2,
    health: 15
  },
  {
1 Like

But also, remember that you need to pass in the index for the monsters array to get the current monster

take a close look at the attack function to see how to correctly used bracket notation to get the current index for the monsters array from earlier

function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
  health -= monsters[fighting].level;
1 Like

Done it was a declaration error, Your help is appreciated

1 Like