Task:
On a new line, use the addition assignment operator(+=
), to add the string " You attack it with your <weapon>."
to the text
value, replacing <weapon>
with the player’s current weapon. Additionally, remember that this line of text starts with a space so it will properly display.
Code:
function attack() {
text.innerText = “The " + monsters[fighting].name + " attacks.”;
text.innerText = " You attack it with your ";
text.innerText += weapons[currentWeapon].name;
WARNING:
You should use dot notation to access the innerText property of text on a new line.
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 118