Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

263
Views
Bingo game problem: all elements of array in another array

I have a small problem. I have an array of 5 winning numbers and a random array draw of 10 numbers between 1 and 26. If all the elements of the winning array are found in the draw array, it should return WIN and LOSE if they aren't. It doesn't work. :(

function bingo(a) {
  let draw = [];
  let win = [2, 9, 14, 15, 7];
  for (let i = 10; i > 0; i--) {
    draw.push(Math.floor(Math.random() * 26 + 1));
  }
  if (win.every((r) => draw.includes(r))) {
    return "WIN";
  } else {
    return "LOSE";
  }
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As I understand from your question, you are just confused because of low probability of matching. You can test it with a constant array to see. However, I see that you are using argument a that does not have any functionality in your function since you define and use just arrays draw and win inside the function

function bingo() {
  let draw = [];
  let win = [2, 9, 14, 15, 7];
  for (let i = 10; i > 0; i--) {
    draw.push(Math.floor(Math.random() * 26 + 1));
  }
  //Here you can change draw with [2, 9, 14, 15, 7] to test
  if (win.every((r) => draw.includes(r))) {
    console.log(draw);
    return "WIN";
  } else {
    console.log(draw);
    return "LOSE";
  }
}

bingo();

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!