--- id: 62a7bf06d2ad9d1c5024e833 title: Step 40 challengeType: 0 dashedName: step-40 --- # --description-- You will also need to update the functions that run when the buttons are clicked again. In your `goStore()` function, update the `onclick` property for each button to run `buyHealth`, `buyWeapon`, and `goTown`, respectively. # --hints-- You should use dot notation to access the `onclick` property of `button1`. ```js assert.match(code, /button1\.onclick/); ``` You should not use `let` or `const` to access the `onclick` property of `button1`. ```js assert.notMatch(code, /(let|const)\s+button1\.onclick/); ``` You should set the `onclick` property of `button1` to be `buyHealth`. ```js assert.match(code, /button1\.onclick\s*=\s*buyHealth/); ``` You should set the `onclick` property of `button1` in your `goStore` function. ```js assert.match(goStore.toString(), /button1\.onclick\s*=\s*buyHealth/); ``` You should use dot notation to access the `onclick` property of `button2`. ```js assert.match(code, /button2\.onclick/); ``` You should not use `let` or `const` to access the `onclick` property of `button2`. ```js assert.notMatch(code, /(let|const)\s+button2\.onclick/); ``` You should set the `onclick` property of `button2` to be `buyWeapon`. ```js assert.match(code, /button2\.onclick\s*=\s*buyWeapon/); ``` You should set the `onclick` property of `button2` in your `goStore` function. ```js assert.match(goStore.toString(), /button2\.onclick\s*=\s*buyWeapon/); ``` You should use dot notation to access the `onclick` property of `button3`. ```js assert.match(code, /button3\.onclick/); ``` You should not use `let` or `const` to access the `onclick` property of `button3`. ```js assert.notMatch(code, /(let|const)\s+button3\.onclick/); ``` You should set the `onclick` property of `button3` to be `goTown`. ```js assert.match(code, /button3\.onclick\s*=\s*goTown/); ``` You should set the `onclick` property of `button3` in your `goStore` function. ```js assert.match(goStore.toString(), /button3\.onclick\s*=\s*goTown/); ``` # --seed-- ## --seed-contents-- ```html RPG - Dragon Repeller
XP: 0 Health: 100 Gold: 50
Monster Name: Health:
Welcome to Dragon Repeller. You must defeat the dragon that is preventing people from leaving the town. You are in the town square. Where do you want to go? Use the buttons above.
``` ```css body { background-color: #0a0a23; } #text { background-color: #0a0a23; color: #ffffff; padding: 10px; } #game { max-width: 500px; max-height: 400px; background-color: #ffffff; color: #ffffff; margin: 30px auto 0px; padding: 10px; } #controls, #stats { border: 1px solid #0a0a23; padding: 5px; color: #0a0a23; } #monsterStats { display: none; border: 1px solid #0a0a23; padding: 5px; color: #ffffff; background-color: #c70d0d; } .stat { padding-right: 10px; } button { cursor: pointer; color: #0a0a23; background-color: #feac32; background-image: linear-gradient(#fecc4c, #ffac33); border: 3px solid #feac32; } ``` ```js let xp = 0; let health = 100; let gold = 50; let currentWeaponIndex = 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; --fcc-editable-region-- function goStore() { button1.innerText = "Buy 10 health (10 gold)"; button2.innerText = "Buy weapon (30 gold)"; button3.innerText = "Go to town square"; } --fcc-editable-region-- function goCave() { console.log("Going to cave."); } function fightDragon() { console.log("Fighting dragon."); } ```