Role Playing Game Step 174

Here is the full question:

" Inside your for loop, use the += operator to add to the end of text.innerText. Add the number at index i of the numbers array, using numbers[i]. Then add a new line, using the escape sequence you used earlier."

Here is my code:

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

When I followed the same syntax above when doing a new line after the string it worked fine… I also tried escaping the \ with single and double quotes and it still didnt work.

Any help appreciated!

This is a string. What do you have to wrap this in to make it a string in JS?

Ive tried placing just the \n in double quotes to make it a string, and it doesnt work :confused: maybe more than just the \n needs to be wrapped?

Please paste your updated code in here so we can see exactly what you did.

When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

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

This is better. You now have the \n string wrapped in quotes. But is this how you concatenate a variable and a string? Look just above this loop to see how you did it previously.