javascript foreach object
const list = {
key: "value",
name: "lauren",
email: "[email protected]",
age: 30
};
// Object.keys returns an array of the keys
// for the object passed in as an argument.
Object.keys(list).forEach(val => {
let key = val;
let value = list[val];
console.log(`${key} : ${value}`);
});
// Returns:
// "key : value"
// "name : lauren";
// "email : [email protected]"
// "age : 30"