Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

264
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda