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

157
Views
Is it possible that I have two different object types in this dictionary? The face cards are printing differently in the console and I don't know why

Hi I'm a student and I'm trying to make a deck of cards that contains objects for each card in the deck. I ran into a problem when linking the image file name to the face cards and here is my solution. It works, but the problem is that the face cards are now formatted differently in the console than the number cards. I'm worried that this may cause problems in my code later on. Is there a reason for this?? Thanks

var deck = [];
//initalizes variables

function createDeck(){
    class Card {
        constructor(rank, suit, img) {
            this.rank = rank;
            this.suit = suit;
            this.img = `images/${rank}_of_${suit}.png`
        };
    };

    let suits = ["hearts", "spades", "diamonds", "spades"];
    
    for (let i = 0; i<suits.length; i++){
        for (let x = 1; x<=13; x++){
            let newCard = new Card(x, suits[i])
            deck.push(newCard);
        }
    };

    function faceCard(face){
        let faceRanks= {
            1: 'ace',
            11: 'jack', 
            12: 'queen',
            13: 'king', 
        };
        face.img= `images/${faceRanks[face.rank]}_of_${face.suit}.png`;
    };

   for (let i=0; i<deck.length; i++){  
       if (deck[i].rank==1 || deck[i].rank>10) faceCard(deck[i]);
    }
 
};
createDeck();
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!