Basic javascript-step 43

Hi,
im experiencing this type of error.
You should update the innerText property within your goStore function.

let xp = 0;
let health = 100;
let gold = 50;
let currentWeapon = 0;
let fighting;
let monsterHealth;
let inventory = ["stick"];

const button1 = document.querySelector('#button1');
const button2 = document.querySelector("#button2");
const button3 = document.querySelector("#button3");
const text = document.querySelector("#text");
const xpText = document.querySelector("#xpText");
const healthText = document.querySelector("#healthText");
const goldText = document.querySelector("#goldText");
const monsterStats = document.querySelector("#monsterStats");
const monsterName = document.querySelector("#monsterName");
const monsterHealthText = document.querySelector("#monsterHealth");

// initialize buttons
button1.onclick = goStore;
button2.onclick = goCave;
button3.onclick = fightDragon;

function goStore() {
  button1.innerText = "Buy 10 health (10 gold)";
}

function goCave() {
  button2.innerText = "Buy weapon (30 gold)";
}
function fightDragon() {
  button3.innerText = "Go to town square";
}

You need to update innerText property only within your goStore function. You placed it in all your function. Cut and paste your button2 and button3 innerText property and it’s value to goStore function. Your test will pass.
@magdalinemumbi573

So button2 and button3 should be in goStore?

For this challenge step yes, It should be within gostore function.
@magdalinemumbi573

Got it. It worked. Thanks

1 Like