Learn Basic JavaScript by Building a Role Playing Game - Step 106

Tell us what’s happening:

text.innerText concatenation says I need to use the concatenation operator. when i did it exactly like this in the function before.
I do not know what I am doing wrong on this step.

### Your code so far

function sellWeapon() {
  if (inventory.length > 1) {
    gold += 15;
    goldText.innerText = gold;
    let currentWeapon = inventory.shift();
    text.innerText += "You sold a  " + currentWeapon + ".";

  }
  
}

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn Basic JavaScript by Building a Role Playing Game - Step 106

Hello!

Do you remember what “+=” is the short form of? Does it make sense to use it here when you actually just want to assign a new text to text.InnerText?

(Sorry for being so cryptic: To avoid getting marked as spoiler you learn to dance around :wink: here)

1 Like

Oh no problem… I’m fine with updating the text… but the instructions specifically say to concatenate the current string in the text element. When i just try and update it, it says to use the concatenation operator.

You have two issues

No.1

You need to use the assignment operator here. Not the compound addition operator.

No.2
You need to remove this extra space here

It looks like you added two spaces instead of just one.

When I fix those things in your code passes for me

1 Like

Delete this part:
text.innerText += " In your inventory you have: " + inventory;