What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-21 01:23:21
javascript foreach in object
const students = { adam: {age: 20}, kevin: {age: 22}, }; Object.entries(students).forEach(student => { // key: student[0] // value: student[1] console.log(`Student: ${student[0]} is ${student[1].age} years old`); }); /* Output: Student: adam... Add solution -
Javascript 2021-11-20 23:50:18
object.keys javascript
// Object Entries returns object as Array of [key,value] Array const object1 = { a: 'somestring', b: 42 } Object.entries(object1) // Array(2) [["a", "something"], ["b", 42]] .forEach(([key, value]) => console.log(`${... Add solution -
Javascript 2021-11-13 05:07:11
foreach object js
const students = { adam: {age: 20}, kevin: {age: 22}, }; Object.entries(students).forEach(student => { // key: student[0] // value: student[1] console.log(`Student: ${student[0]} is ${student[1].age} years old`); }); /* Output: Student: adam... Add solution