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

Tell us what’s happening:

Inside your if statement, check if the guess is in the numbers array using the .includes() method. This is the hint that I am getting and I’m confused as to what to do here since I’m using the guess.includes function.

Your code so far

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";
  } if (someArray.indexOf(someThingToCheckFor) !== -1){


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 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

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

First hint, you shouldn’t put anything inside of the if block. The instructions are only asking you to create the if statement itself. So you will have an if statement with curly braces and then nothing inside the braces.

Second hint, read the instructions again closely.

“…add an if statement to check if the guess is in the numbers array.”

Which array do you want to check? I think that the conditional for your if statement should probably include that array, don’t you :slightly_smiling_face:

if (guess.includes(numbers !== -1)){
I gave this a try and it doesn’t work either

Remember, the includes method is part of the Array, so you call it on an array.

if (numbers.includes(guess) !== -1) {
Tried this but not close either.

Never mind I figured it out thanks for the help

1 Like


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