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

178
Visualizações
getting undefined after .push() objects from Constructor json

Hi im trying to acces my data but geting undefined console.log(creature.species). the output for console.log(creature) is: console.log(craeture)

and here is my code:

    function Creature(species, weight, height, diet, where, when, fact, name) {
    this.species = species;
    this.weight = weight;
    this.height = height;
    this.diet = diet;
    this.where = where;
    this.when = when;
    this.fact = fact;
    this.name = name;

}
//Get dinoData from dino.json and Create Dinosaurs
let creature = [];
console.log(creature)

function createDino() {
    return fetch("dino.json")
        .then(function(response) {
            return response.json();
        })
        .then(function({ Dinos }) {
            Dinos.map(function(dinosaurs) {
                let dino = new Creature(...Object.values(dinosaurs));
                delete name;
                creature.push(dino);
            })
        })
};
createDino();

console.log(creature.species)
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