Answers for "create object loop javascript"

85

javascript loop through object

Object.entries(obj).forEach(
    ([key, value]) => console.log(key, value)
);
Posted by: Guest on February-15-2020
0

for loop on object js

// an easy way is to

const obj = {1: 'a', 2: 'b', 3: 'c',};

for (const i in obj)
  console.log(obj[i]);

//it is a simple way to loop on values of an object
Posted by: Guest on August-31-2021
0

javascript looping through object

for (const [fruit, count] of entries) {
  console.log(`There are ${count} ${fruit}s`)
}

// Result
// There are 28 apples
// There are 17 oranges
// There are 54 pears
Posted by: Guest on May-19-2020

Code answers related to "create object loop javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language