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

113
Vistas
Why wont the value change in the array?

why is it console.logging the array with all zeroes??

im clearly changing value but its still console.logging with just zeroes

let a = 0,
    b = 0,
    c = 0,
    d = 0,
    e = 0
    f = 0,
    g = 0,
    h = 0,
    i = 0;

const test = document.querySelector(".test");
test.addEventListener("click", () => {
    a = 1;
    b = 1;
    c = 1;
    gameBoard.winConditions;
    console.log(gameBoard.winConditions)
})

const gameBoard = {
    winConditions: [[a, b, c], [a, d, g], [a, e, i], [b ,e, h], [c, e, g], 
                   [c, f, i], [d, e, f], [g, h, i]]
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

gameBoard.winConditions; this line does nothing. When updating the a,b,c... variables, the winConditions stay the same. I would recommend to write a function to re-evaluate the value of winConditions:

let a = 0,
    b = 0,
    c = 0,
    d = 0,
    e = 0
    f = 0,
    g = 0,
    h = 0,
    i = 0;

const test = document.querySelector(".test");
test.addEventListener("click", () => {
    a = 1;
    b = 1;
    c = 1;
    applyWinConditions();
    console.log(gameBoard.winConditions)
})

const gameBoard = {};

applyWinConditions(); // set the win conditions initially

function applyWinConditions() {
  gameBoard.winConditions = [[a, b, c], [a, d, g], [a, e, i], [b ,e, h], [c, e, g], [c, f, i], [d, e, f], [g, h, i]];
}
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