Now update the goldText element to display the new value of gold , and update the text element to display "You now have a new weapon."
/* This What i Write to change the gold = inner text ? but it's not passing my code */someone help me out with this
function buyWeapon() {
if (gold >= 30) {
gold -= 30;
currentWeapon++;
goldtext.innerText = "You now have a new weapon.";
}
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 85
Look at the code in the buyHealth function. Both lines of code you are asked to write inside the buyWeapon function are already in the buyHealth function.
function buyHealth() {
if (gold >= 10) {
gold -= 10;
health += 10;
// this is the same line you are asked to write again inside buyWeapon
goldText.innerText = gold;
healthText.innerText = health;
} else {
// this is the same line you are asked to write again inside buyWeapon, but with the new weapon text
text.innerText = "You do not have enough gold to buy health.";
}
}