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

Tell us what’s happening:

I dont know why my code isnt working. Ive used Math.floor and Math.random as well and also, included the +1 at the end.

Your code so far

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

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

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

// User Editable Region
/* file: styles.css */

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

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

you can’t have a multiplication without the first operand

set gold equal to gold plus the monster’s level times 6.7 .

You are not multiplying monsters[fighting].level by 6.7. Trying multiplying directly. To round the result down, enclose that whole expression within the parentheses of the Math.floor() method.

Got it! That worked. Thank you :slight_smile:

1 Like