how to take looop on objects code example
Example 1: how to loop trough an object java script
// Looping through arrays created from Object.keys
const keys = Object.keys(fruits)
for (const key of keys) {
console.log(key)
}
// Results:
// apple
// orange
// pear
Example 2: loop key in object
const fruits = { apple: 28, orange: 17 }
for(key in fruits){
console.log(key)
}