Tell us what’s happening:
I get the correct property value when I logged the object alongside the property name to the console using bracket notation. However, I’m still not getting pass this exercise.
Your code so far
const tiger = {
species: "Tiger",
age: 5,
isEndangered: true
};
const elephant = {
species: "Elephant",
age: 10,
isEndangered: true
};
const getSpecies = (animal) => {
return animal.species;
};
console.log(getSpecies(tiger));
const getAge = (animal) => {
return animal.age;
};
console.log(getAge(tiger));
const addHabitat = (animal, habitat) => {
animal.habitat = habitat;
return animal;
};
console.log(addHabitat(tiger, "Rainforest"));
const updateAge = (animal, newAge) => {
animal.age = newAge;
return animal;
};
console.log(updateAge(elephant, 12));
const removeEndangeredStatus = (animal) => {
delete animal.isEndangered;
return animal;
};
console.log(removeEndangeredStatus(tiger));
const hasHabitat = (animal) => {
return animal.hasOwnProperty("habitat");
};
console.log(hasHabitat(tiger));
console.log(hasHabitat(elephant));
// User Editable Region
function getProperty (animal, propertyName) {
animal[species] = propertyName;
return animal;
}
console.log(getProperty (tiger, "species"));
console.log(getProperty (elephant, "age"));
// User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
Challenge Information:
Build a Wildlife Tracker - Step 12