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
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 + ".";
}
}
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 + ".";