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

Tell us what’s happening:

I’m not too sure what I am missing here. It says to replace with the name of the monster I am using, but I am not using a monster yet as it has only told me to edit the goFight() function. There is no code in any of the monster specific sections yet.

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

function attack() {
  text.innerText = "The Dragon attacks."
}

// User Editable Region

Your browser information:

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

Hi @LowVel0city

Look inside the monsters object.

You used similar code to access the health property a few steps ago.

Happy coding

This is what its asking of me
image

not sure how I am supposed to properly call the monster name when it has the greater and less than signs around it. I don’t understand what the arrows signify.

The instructions for challenge step-117 is:

Add a new object to the end of the locations array, following the same properties as the rest of the objects. Set name to “fight”, “button text” to an array with “Attack”, “Dodge”, and “Run”, “button functions” to an array with attack, dodge, and goTown, and text to “You are fighting a monster.”.

Hi @LowVel0city

Add a new object to the end of the locations array, following the same properties as the rest of the objects. Set name to "fight" , "button text" to an array with "Attack" , "Dodge" , and "Run" , "button functions" to an array with attack , dodge , and goTown , and text to "You are fighting a monster." .

As @hasanzaib1389 pointed out the instructions want you to add a new object.

It looks like the step may have updated. I saw the same instructions as you did yesterday.

Happy coding

Yes this lesson has been updated so this is actually a question for step 122.

It is asking:
Now you can build the attack function. First, update the text message to say "The <monster name> attacks." , replacing <monster name> with the name of the monster. Remember you can use the concatenation operator for this.

I am unfamiliar with what “monster name” does. I haven’t seen anything like that this far in this lesson.

But then it tells me I should:
You should assign the string The to innerText property of text .

Which doesn’t mention anything about ‘monster name’

Very confusing.

It is also very frustrating I cannot put <> around monster name in these replies…

That is my biggest confusion, where the hell is <> monster name coming from…

I’ve gotten to the point of the below

Is what is said in the console not exactly what I am doing in the code???

HI @LowVel0city !

Please write your code directly in the forum so we can test out your latest changes.
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 (').

I posted the above screen shot to show that I am doing exactly what the console is telling me to do, yet it is still not passing. I know this course is in BETA, so maybe that is the issue. I have found other forums posts with this same solution and their code passes, but mine does not.

Very puzzling.

I can see the screenshot but it best for us to test your code in the editor ourselves to better help you.

Please write your code so we can test it on our end

function attack() {
  text.innerText = "The " + monsters[fighting].name + "attacks."
}

found it.

You are missing the space here

my dear lord… how stupid of me

Earlier in the project, you created a monsters array here

const monsters = [
  {
    name: "slime",
    level: 2,
    health: 15
  },
  {
    name: "fanged beast",
    level: 8,
    health: 60
  },
  {
    name: "dragon",
    level: 20,
    health: 300
  }
]

This is an array of objects.

So monsters[0] would be this first object here

{
    name: "slime",
    level: 2,
    health: 15
  },

monsters[1] would be this second object here

{
    name: "fanged beast",
    level: 8,
    health: 60
  },

monsters[2] would be this object here

 {
    name: "dragon",
    level: 20,
    health: 300
  }

The fighting variable represents an index number.

fighting will either be a 0,1, or 2

When you do monsters[fighting].name you are getting the monster’s name of the currently monster you are fighting.

so if fighting was 0, then monsters[fighting].name would be slime

The text variable is this element right here

When you are fighting a monster, then it should show the monster you are fighting

hope that helps