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

The step says:

Step 165

After the while loop, set text.innerText to equal You picked [guess]. Here are the random numbers:. Replace guess with the player’s guess.

But everytime I do this, I’ve been getting an error message. I’ve googled, used ChatGPT and watched Youtube but nothing has looked different to my code.

Please help, I’ve been stuck on this for a while now.

function pick(guess) {
  let numbers = [];
  while (numbers.length < 10) {
    numbers.push(Math.floor(Math.random() * 11));
  }
  text.innerText = "You picked " +guess+ "";
  text.innerText += " .  Here are the random numbers:";
}

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 165

Hey @Govender108
You are on the right track,just use one text.innerText and concatenate the strings
Give spaces between the +'s and the text guess
Happy coding

I’ve been stuck on this for a few minutes. Nothing is working to resolve it. I’ve moved the spaces so many times.
current submission:
text.innerText += " You picked " + guess + “. Here are the random numbers:”;

I would do this (string literal) if the system would accept it since it’s far more readable and easier:
text.innerText += You picked ${guess} . Here are the random numbers:;

What exactly did you do to resolve the issue?

1 Like

Post your complete code please

function pick(guess) {
let numbers = ;
while (numbers.length < 10) {
numbers.push(Math.floor(Math.random() * 11));
}

text.innerText += " You picked " + guess + “. Here are the random numbers:”;

}

That is my code above and below is the message I’m receiving.
Sorry, your code does not pass. Don’t give up.

You should set text.innerText to the string You picked . Remember that spacing matters.

You need space between the plus sign and the text guess

Like this

+  text  +

It might appear there isn’t any space between the variable and the operator but there is one space between to two. Are you saying I need more than one space? There us is a single space between the operator and the variable [guess] and a single space between the operator and the open quotation mark.

I don’t understand what makes my issue new if it is literally the same issue as the original one posted here. Googling my issue led me to this exact forum. It is an issue regarding inadequate or suspected inadequate spacing on step 165 of the RPG project. The original post was marked SOLVED after someone suggested the issue was related to spacing.

Can you direct me to the page that discusses all forum rules? As a new member, I would like to educate myself on the rules so I don’t violate any. I was only able to read through the guidelines but it didn’t say or at least I didn’t come across what you are emphasizing in your responses. I have seen that I didn’t structure my code the way it is recommended. I also failed to inform others what steps I’d taken to resolve the issue.

No apologies necessary. I only wanted to make sure I remain in compliance because freeCodeCamp is a wonderful resource and it is amazing they are providing such a valuable service for free. That is unheard of in today’s society. So, I want to respect their platform since I already read that I posted my code wrong and I didn’t disclose what measures I took to solve the problem. I know what to do now so I will not make those mistakes again, hopefully. Thanks for the response. Someone on their discord help me discovered where the issue was so I was able to continue with the project.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.