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

Tell us what’s happening:

Why is the auto grader saying the this is wrong ?

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

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

–currentWeapon decrements The auto grader is saying this is wrong. Why ?

if (Math.random() <= .1) {

text.innerText += " Your " + inventory.pop() + " breaks."   ;  

–currentWeapon;
}

Because it wants you to add -- at the end of the variable, not the beginning. Technically, it doesn’t matter in this case, but there is a difference between adding it at the beginning and end of the variable name. And the instructions don’t say that you must put it after the variable name. So this is probably a bug in the step.

For now, if you want to pass this step, then place it after the variable name.

Also, for future reference, please use the following method to paste your code in here so that we can read it properly.

To display your code in here you need to wrap it in triple back ticks. On a line by itself type three back ticks. Then on the first line below the three back ticks paste in your code. Then below your code on a new line type three more back ticks. The back tick on my keyboard is in the upper left just above the Tab key and below the Esc key. You may also be able to use Ctrl+e to automatically give you the triple back ticks while you are typing in the this editor and the cursor is on a line by itself. Alternatively, with the cursor on a line by itself, you can use the </> button above the editor to add the triple back ticks.

1 Like

Thanks for your kind reply ! Do not understand about the tripple back ticks. Is there a you tube video on how to ask a question ? When I create the questions there is a warning about it taking up too much room and put code in a particular spot. It does not seem like that works though.

You can look for this button in the editor. Backtick shares the “tilde” button on the keyboard, it kind of looks like a single quote

Screenshot 2023-09-03 082302

Feel free to ask questions. I outlined three different ways to paste your code in here properly. And @pkdvalis showed you one of them with an image. You will need to learn how to paste your code in here properly. Otherwise, people aren’t going to be as willing or able to help you because they won’t be able to test your code properly.

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