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

110
Views
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
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!