This is how to output data using Object.entries(parameter). Object.entries() is a method used in getting an array of keys and values from an object. Read more MozillaMDN
let profile = {
"first name": "Chinwendu",
"last name": "Agbaetuo",
"age": 53
};
const details = Object.entries(profile);
for(let index = 0; index < details.length; index++) {
console.log(`My ${details[index][0]} is ${details[index][1]}`)
}
Result
> "My first name is Chinwendu"
> "My last name is Agbaetuo"
> "My age is 53"
Top comments (0)