I tried to find the answer but nothing that I found works... I have an object with properties. There's a separate function that writes a sentence using these propereties. The result I want is "Bob is a 12 years old small turtle.". How can I put the name(not name-properity) of the object into this sentence so it writes 'turtle'?
const turtle = {
name: "Bob",
age: 12,
size: 'small'
}
const writeBio = (animal) => {
// my attempts:
let type = animal; // doesn't work, it writes "Bob is a 12 years old small [object Object]."
let type = Object.keys(animal)[0]; // doesn't work, it writes "...name."
let type = animal.constructor.name; // doesn't work, it writes "...Object."
const {name, size, age} = animal;
console.log(`${name} is a ${age} years old ${size} ${type}.`);
}
writeBio(turtle);