How do I access the properties of james and obtain the below output using console.log statements
console.log(iterator.next().value); 'James'
console.log(iterator.next().value); 5'10
console.log(iterator.next().value); 185
const james = {
name: 'James',
height: `5'10"`,
weight: 185};
const key=Object.keys(james);
const iterator = james[[Symbol.iterator]]();
Turn the james object into an iterable object.
- Each call to iterator.next should log out an object with the following info:
- key: the key from the
jamesobject- value: the value of the key from the
jamesobject - done: true or false if there are more keys/values
- value: the value of the key from the
I'm new to JavaScript and programming..
Thanks in advance
Object.keys(james).forEach(prop => {console.log(james[prop])});.