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

Tell us what’s happening:

I don’t understand why this is not getting accepted please can anyone help first time doing java!

Your code so far

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

/* file: styles.css */

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

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    currentWeapon++;
    goldText.innerText = gold;
    let newWeapon = weapons[currentWeapon].name;
    text.innerText = "You now have a ";
    const weapon = "new weapon";
    const newStr = "You now have a " + weapon + ".";
  }
}

// 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 94

I don’t see an else statement here? Please show us what you have tried!


Note - Java and JavaScript are very, very different. This is JavaScript :wink:

ik i was just shorting it out sorry but here is the code

function buyWeapon() {
  if (gold >= 30) {
    gold -= 30;
    currentWeapon++;
    goldText.innerText = gold;
    let newWeapon = weapons[currentWeapon].name;
    text.innerText = "You now have a ";
    const weapon = "new weapon";
    const newStr = "You now have a " + weapon + ".";
  }
}

I still don’t see the word else anywhere though? Where did you try to add the else that the instructions asked for?

it dosen’t say to add a else statement

You can insert variables into a string with the concatenation operator +. Update the "You now have a new weapon." string to say "You now have a " and the name of the new weapon. Remember to end the sentence with a period.

Here is an example that creates the string "Hello, our name is freeCodeCamp.":

const ourName = "freeCodeCamp";
const ourStr = "Hello, our name is " + ourName + ".";

oh mine says something different

OHHH I HAD TO REFRESH sorry!!!

1 Like