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

Tell us what’s happening:

I can’t use the “Pop method”

Your code so far

if (Math.random() <= .1) {
text.innerText += " Your " + currentWeapon.name + “breaks.” ;
inventory.pop()

Error message:

You should add the return value of inventory.pop() to the Your string.

Challenge Information:

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

The error is saying: " You should add the return value of inventory.pop() to the Your string." try to put the inventory.pop() inside of the string, remember when you are using the pop, you are deleting the last string in the array inventory, replace the currentWeaponName with the pop, it will show the value like that: text.innerText += " Your " + inventory.pop() + " breaks.";

if (Math.random() <= .1) {
text.innerText += " Your " + inventory.pop() + " breaks.";

This worked, thank you so much!

1 Like

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