how to use if(math.random == 50)? [closed]

Instead of using Math.floor(Math.random() * 100) twice, use it only once because every time it will generate a new number and assign it to a variable & check if that is between 50 & 60. The result of Math.floor(Math.random() * 100) inside console.log(); & if () is very unlikely to be equal. So even if you see the number logs is in the range but rarely it will be the same number inside the if‘s conditional statement

let opengg = function() {
  let num = Math.floor(Math.random() * 100);
  console.log(num)
  if (num >= 50 && num <= 60) {
    console.log("test")
  }
}

opengg();

Leave a Comment