Tell us what’s happening:
Hey everyone kindly guide me with this one; my instruction is below;
" 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."
my code is below;
function attack() {
text.innerText = "The <monster name> attacks.";
}
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15
Challenge Information:
Learn Basic JavaScript by Building a Role Playing Game - Step 118
“…replacing <monster name>
with the name of the monster.”
You didn’t do this part. I’d look at the goFight
function to see how you got the monster’s name previously.
1 Like
Appreciate your reply. I tried this;
function attack() {
text.innerText = "The" + monsters[fighting].name + "attacks.";
}
Your close but you have spacing issues
This is what your current code looks like
1 Like
Thanks for guidance. spacing issues? kindly throw more light.
You probably want that to say something like ‘the slime attacks’ instead of ‘theslimeattacks’ right?
You should have three seperate words instead of one large word.
You need to make changes here
Answer_Alyosha:
"The"
and here
Answer_Alyosha:
"attacks.
to pass the test.
hope that is clearer
1 Like
ostensibly it isn’t clear.
function attack() {
text.innerText = "The" + "monsters[fighting].name" + "attacks.";
}
1 Like
Let’s go back to your earlier attempt here because that was closer to the answer
Do not change this
Answer_Alyosha:
monsters[fighting].name
that is correct
You need to make chagnes here
Answer_Alyosha:
"The"
you need a space at the end of that string
and you need to make changes here
Answer_Alyosha:
"attacks."
you did something similar here in an earlier step
Here is code you wrote from your sellWeapon function
text.innerText = "You sold a " + currentWeapon + ".";
notice the space here
"You sold a "
you need to do something similar here
Answer_Alyosha:
"The"
and you need a space before the word here
Answer_Alyosha:
"attacks."
once you fix those spacing issues, then the test will pass the correctly return the sentence
The slime attacks
instead of showing
Theslimeattacks
1 Like
Appreciate for walking me through it and your patience. I tried this below;
function attack() {
text.innerText = "The " + monsters[fighting].name + " attacks";
}
1 Like
Super close
You forgot the period here after the word attacks
Answer_Alyosha:
" attacks"
you had it earlier here but might have accidently deleted it when making revisions
Answer_Alyosha:
acks."
once you add that in, then the test will pass
2 Likes
Really truly appreciate your patience with me. it worked.
2 Likes
system
Closed
August 7, 2024, 9:00am
13
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.