Make An Iterable Object

/*

 * Programming Quiz: Make An Iterable Object

 *

 * 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 `james` object

 *     - value: the value of the key from the `james` object

 *     - done: true or false if there are more keys/values

 *

 * For clarification, look at the example console.logs at the bottom of the code.

 */


const james = {

    name: 'James',

    height: `5'10"`,

    weight: 185

};


let iterator = james[Symbol.iterator]();


console.log(iterator.next().value); // 'James'

console.log(iterator.next().value); // `5'10`

console.log(iterator.next().value); // 185

这一题怎么写呀?

相关知识链接:https://segmentfault.com/a/11...
我看了网上的资料,试了好几遍都不对,求大佬们帮忙解决?


繁花不似锦
浏览 547回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript