for.. loop in JavaScript
Chinwendu Agbaetuo
Posted on April 11, 2024
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"
💖 💪 🙅 🚩
Chinwendu Agbaetuo
Posted on April 11, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.