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

Tell us what’s happening:

Your code so far

it say i should use set the monsterHealth to be the health of the current monster. You can get this value by accessing the health property of monsters[fighting] with dot notation. set the monsterHealth to be the health of the current monster. You can get this value by accessing the health property of monsters[fighting] with dot notation.
and i have tried different option it not working , please can someone help me out, Thanks in advance

function goFight() {
  update(locations[3]);
  
}

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) 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 116

monsters[fighting].health
monsters is an array of objects
you access the current monster object which is the value of fighting
you access the health value within this object with .health
const monsters = [
{ name: ‘slime’, level: 2, health: 15 },
{ name: ‘fanged beast’, level: 8, health: 60 },
{ name: ‘dragon’, level: 20, health: 300 }

please i don’t can you explain

You need to post the code you have tried, otherwise we can’t tell what you’re doing wrong.

[Below your update call, set the monsterHealth to be the health of the current monster. You can get this value by accessing the health property of monsters[fighting] with dot notation.] i don’t really understand what to do.
This is the code below

function goFight() {
update(locations[3]);

}

You are just posting the unedited code. I can not help you solve the problem, since I don’t know what you are doing wrong.

Hey, I found the solution to your problem. Try using the snippet below.

function goFight() {
  update(locations[3]);
  monsterHealth = monsters[fighting].health;
}

Let me know if that worked for you.

1 Like

wow yes it did work thanks so much