2.8 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 62a23cb9bc467a147516b500 | Step 14 | 0 | step-14 |
--description--
Erstelle für dein #controls-Element drei button-Elemente. Das erste sollte die id auf button1 gesetzt haben und den Text Go to store enthalten. Das zweite sollte die id auf button2 gesetzt haben und den Text Go to cave enthalten. Das dritte sollte die id auf button3 gesetzt haben und den Text Fight dragon enthalten.
--hints--
Du solltest drei button-Elemente zu deinem #controls-Element hinzufügen.
const buttons = document.querySelectorAll('#controls > button');
assert.exists(buttons);
assert.equal(buttons.length, 3);
Deine erste Schaltfläche sollte die id auf button1 gesetzt haben.
const buttons = document.querySelectorAll('#controls > button');
const button1 = buttons[0];
assert.equal(button1.id, 'button1');
Deine erste Schaltfläche sollte den Text Go to store haben.
const buttons = document.querySelectorAll('#controls > button');
const button1 = buttons[0];
assert.equal(button1.innerText, 'Go to store');
Deine zweite Schaltfläche sollte die id auf button2 gesetzt haben.
const buttons = document.querySelectorAll('#controls > button');
const button2 = buttons[1];
assert.equal(button2.id, 'button2');
Deine zweite Schaltfläche sollte den Text Go to cave haben.
const buttons = document.querySelectorAll('#controls > button');
const button2 = buttons[1];
assert.equal(button2.innerText, 'Go to cave');
Deine dritte Schaltfläche sollte die id auf button3 gesetzt haben.
const buttons = document.querySelectorAll('#controls > button');
const button3 = buttons[2];
assert.equal(button3.id, 'button3');
Deine dritte Schaltfläche sollte den Text Fight dragon haben.
const buttons = document.querySelectorAll('#controls > button');
const button3 = buttons[2];
assert.equal(button3.innerText, 'Fight dragon');
--seed--
--seed-contents--
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="./styles.css">
<title>RPG - Dragon Repeller</title>
<script src="./script.js"></script>
</head>
<body>
<div id="game">
<div id="stats">
<span class="stat">XP: <strong><span id="xpText">0</span></strong></span>
<span class="stat">Health: <strong><span id="healthText">100</span></strong></span>
<span class="stat">Gold: <strong><span id="goldText">50</span></strong></span>
</div>
--fcc-editable-region--
<div id="controls">
</div>
--fcc-editable-region--
<div id="monsterStats"></div>
<div id="text"></div>
</div>
</body>
</html>
let xp = 0;
let health = 100;
let gold = 50;
let currentWeaponIndex = 0;
let fighting;
let monsterHealth;
let inventory = ["stick"];