function attack() {
text.innerText = "The " + monsters[fighting].name + " attacks. ";
}
error
** You should use the concatenation operator to add the string attacks.to the** monsters[fighting].name string.
Step 117
Now you can build the attack function. First, update the text message to say "The <monster name> attacks.", replacing <monster name> with the name of the monster. Remember you can use the concatenation operator for this.
but still showing error i dont know what is the problem in this code…pls some one tell me. let me correct it…
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 117
The error message suggests that you should use the concatenation operator to combine the string “attacks” with the name of the monster.
In JavaScript, the concatenation operator is +. If you’re already using + to concatenate strings in your code, the issue might be elsewhere. However, to address the error message directly, you can rewrite the attack() function like this:
function attack() {
text.innerText = “The " + monsters[fighting].name + " attacks.”;
}
This will properly concatenate the strings without triggering the error. Make sure text and monsters are properly defined elsewhere in your code.