Where is the mistake guys
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldText.innerText = gold;
let newWeapon = weapons[currentWeapon].name;
text.innerText += " In your inventory you have: " + newWeapon + β.β;
inventory.push(newWeapon);
}
}
Teller
2
Welcome to the forum @ahmedbouhrira365
You replaced the existing text.innerText
variable.
The instructions want you to add your code on a new line.
Happy coding
1 Like
The issue in your code appears to be with the string concatenation in the line:
text.innerText += " In your inventory you have: " + newWeapon + β.β;
It seems youβre using curly quotes ββ
around the period at the end of the line, which might be causing a syntax error.
Replace the curly quotes with straight quotes "
:
text.innerText += " In your inventory you have: " + newWeapon + ".";
After making this change, your function should work correctly.
2 Likes
system
Closed
4
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.