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

The tasks says that I should do this " Inside your while loop, push a random number between 0 and 10 to the end of the numbers array. You can create this random number with Math.floor(Math.random() * 11) ."

function pick(guess) {
  const numbers = [];
  while (numbers.length < 10) {
    let randomNumber = Math.floor(Math.random() * 11);
    numbers.push(randomNumber);
  }
}

Please what am i doing wrong

let randomNumber = Math.floor(Math.random() * 11);
    numbers.push(randomNumber);

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 162

You don’t need the random number variable.

You can add that Math.floor expression right in the push method to pass

2 Likes

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