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

Tell us what’s happening:

Not sure how to add in the lose function as there is no lose function available to call upon

Your code so far

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

/* file: styles.css */

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

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){
    call(function lose());
  }
}

// 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/124.0.0.0 Safari/537.36

Challenge Information:

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

you can call functions before creating them, maybe there will be a next step in which you create a function like that, it happens often in this project, doesn’t it?

this is the wrong way to call a function

1 Like

for calling a function, you only need that function’s name.
@aayushsinghsong

ok thanks, just figured it out!