JavaScript Role-Playing Game step 175

This is the current instructions:
Step 175
The .includes() method determines if an array contains an element and will return either true or false.

Here is an example of the .includes() syntax:

const numbersArray = [1, 2, 3, 4, 5]
const number = 3

if (numbersArray.includes(number)) {
  console.log("The number is in the array.")
}

After your for loop, add an if statement to check if the guess is in the numbers array. You can use the .includes() method to check if the array contains the guess.

Here is what I have:

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 (numbersArray.includes(guess)) {
      
    }
    }

Help, Iā€™m not sure how many other ways to follow the instructions!

Your issue is here

there is no variable called numbersArray in your code.

The array the directions are referring to is the array you created here

once you fix that, then the test will pass

1 Like

Thank you !!! I got it!!

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