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

Tell us what’s happening:

Not sure when or how to include /n.

Your code so far

question:
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.

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” ;
}

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/121.0.0.0 Safari/537.36

Challenge Information:

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

Welcome back to the forum @abigail.figaro

Remove the space before the new line character.

For next time…
Use the following method to post code to the forum:

  1. On a separate line type three back ticks.
  2. On a separate line paste your code.
  3. On the last line type three back ticks. Here is a single back tick `

Happy coding

You’re using a different type of quotation mark () instead of the standard double quotation mark ("). Also, you’ve forgotten to define the text variable, which I assume should be a reference to some HTML element where you want to display the text.

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”;
}
Make sure to define the text variable properly and use the correct quotation marks, and your code should work as intended.

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