Question from the Node.js test

Write a NodeJS code that will print the keys of an object in an array

Hard

Considering a generator allowing items to be returned:

function *getItems() {
  let items = [
    {foo:'bar'},
    {baz:'qux'},
    {quux:'corge'}
  ];

  while (items.length > 0)
    yield items.pop();
}

What will the following code display?

for (let item of getItems()) {
  console.log(Object.keys(item));
}
Author: Jean-marie CléryStatus: PublishedQuestion passed 884 times
Edit
0
Community EvaluationsNo one has reviewed this question yet, be the first!