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

Tell us what’s happening:

Hello Sir/Mam
Kindly help, I don’ t know what to do to pass this code.

Your code so far

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

/* file: styles.css */

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

function defeatMonster() {
  gold += gold + monsters[fighting].level + Math.floor(Math.random() * 6.7);

}

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

Challenge Information:

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

Please talk to us about how the instructions or error message are confusing. Thanks

Hi @olorunlogbon

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

  1. The instructions do no mention using Math.random(), so remove that code.

  2. Also, you are using compound assignment, so you do not need to add the gold variable to the assignment.

  3. In the instructions, you are asked to round the result, your code is rounding half the code.

Happy coding

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.