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

118
Visualizações
Object is not displaying values in console log

My class objects are not displaying from the main object in the console log

// Inventory , the main class

class Inventory{
    constructor(shoe,customer){
        this.shoes = [];
        this.customers = [];
    }

    addShoes(shoe){
        this.shoes.push(shoe);
    }

    addCustomers(customer){
        this.customers.push(customer);
    }
}

// Customer class

class Customer{
    constructor(name,address,phone){
        this.name = name;
        this.address = address;  
        this.phone = phone;
    }
}

//Shoes class

class Shoes{
    constructor(brand,name,color,size){
        this.brand =  brand;
        this.name = name;
        this.colors = [];
        this.sizes = [];
    }

    addColors(color){
        this.colors.push(color);
    }

    addSizes(size){
        this.sizes.push(size);
    }
}

// Where I put in the data for the object values, to display to console log

const inventory = new Inventory();

const myko = new Customer("Myko","216 Peachtree",9144444444);

const shoes = new Shoes("Nike","Air Force 1");
      shoes.addColors(["Black/Green","Blue/white","Red/Blue","White/Red"]);
      shoes.addSizes([12,10,9,11]);


const newAdd = new Inventory(shoes,myko);

console.log(newAdd);

what my console log displays , empty data

Inventory {shoes: Array(0), customers: Array(0)} customers: Array(0)


I want the console log to display , when I put in the data when I call the Inventory class in console.log

Inventory {shoes: Array(1), customers: Array(1)}

customers: "Myko" , "216 Peachtree" , 9144444444"

shoes: "Nike", "Air Force 1", "Black/Green", "Blue/white", "Red/Blue", "White/Red", 12, 10, 9, 11

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You didn't initiallize the inventory with the parameter in the constructor. ([] instead.)

class Inventory{
    constructor(shoe,customer){
        this.shoes = shoe;
        this.customers = customer;
    }
}
about 4 years ago · Juan Pablo Isaza Relatório
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