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

Hello, i am stuck at this step . i need help.

function attack() {
  text.innerText = "The " + monsters[fighting].name + " attacks.";
  text.innerText += " You attack it with your " + weapons[currentWeapon].name + ".";
  health -= monsters[fighting].level;
  monsterHealth -= weapons[currentWeapon].power + Math.floor(Math.random() * xp) + 1;
  healthText.innerText = health;
  monsterHealthText.innerText = monsterHealth;
  if(health <= 0) {
function lose();


You using the incorrect syntax here when calling a function

Drop the function keyword and it will pass

When you call a function you reference the function name followed by a parenthesis.
When you declare a function, that is when you use the function keyword followed by the name of the function.

hope that helps

1 Like

Hello, I was hoping I could get clarification on this. I passed this step thanks to this explanation but I am a little confused because I checked my code and nowhere did I declare “lose” as a function. How can I call a function that was never declared? Unless I am missing something here… thanks

** edit: I spoke too soon, I see I create the function after that step!