Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

111
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda