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

112
Vistas
JavaScript arrays undefined after pushing onto another array

I'm writing some JavaScript that will eventually display a tarot spread. Right now, I'm having trouble with a two dimensional array of cards, two dimensions because I need to keep track of the orientation of the cards.

Part of the file so far:

const DeckSize = "78";

function TarotCard(cardNumber, isInverse){
  card=new Array();
  card.push(cardNumber);
  card.push(isInverse);
console.log("new card="+card[0]+" "+card[1]);
}

function TarotDeck(){
  deck=new Array();

  for(i=0; i<DeckSize; i++){
    deck.push(new TarotCard(i, false));
console.log("pushed new card as "+deck[i][0]+" and "+deck[i][1]);
  }
console.log(deck.length);
  return shuffleDeck(deck, 3);
}

The console.log lines give this:

new card=0 false pushed as undefined and undefined

...78 times, of course. I'm not sure where things are going wrong.

about 4 years ago · Juan Pablo Isaza
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