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

Tell us what’s happening:

Hi guys,
I am at one of the final steps of this project and got really stuck with the ask.

Basically, based on this code

I need to: " At the end of the string, before the final quote, insert the new line escape character \n . This will cause the next part you add to text.innerText to appear on a new line.

Your code so far

I have tried multiple options and nothing is working. So by now I am not sure if I cannot get it right, if the instructions are wrong or if there is a bug. Here is everything I tried so far:

  1. text.innerText = "You picked " + guess + ".Here are the random numbers: \n";
  2. text.innerText = "You picked " + guess + "\n.Here are the random numbers: ";
  3. text.innerText = "You picked " + guess + "\n .Here are the random numbers: ";
  4. text.innerText = "You picked " + guess + ".\n Here are the random numbers: ";
  5. text.innerText = "You picked " + guess + \n".Here are the random numbers: ";
  6. text.innerText = "You picked " + guess + "\n" + ."Here are the random numbers:";

And a few more combinations, but this is just to give you an idea. I honestly dont know what else to try.

I appreciate your help and support

function pick(guess) {
  const numbers = [];
  while (numbers.length < 10) {
    numbers.push(Math.floor(Math.random() * 11));
  }
  text.innerText = "You picked " + guess + "\n" + ."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/122.0.0.0 Safari/537.36

Challenge Information:

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

this is the nearest, but you need to have a space after the dot, while you don’t need a space after the colon

1 Like

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