// Practice Set · JS Iterations · guest

Guest practice: this set is not saved and does not count.

Question 1 of 5 from: JS Iterables

What does this log?

const word = "code";
const [first, second] = word;
console.log(first, second, [...word].length);
Question 2 of 5 from: JS Iterables

What does this log?

function isIterable(x) {
  return x != null && typeof x[Symbol.iterator] === "function";
}
console.log(isIterable([1]), isIterable({ a: 1 }), isIterable(new Map()), isIterable(null));
Question 3 of 5 from: JS Generators

What does this log?

function* steps() {
  console.log("start");
  yield "A";
  console.log("end");
}
const g = steps();
console.log("created");
console.log(g.next().value);
Question 4 of 5 from: JS Generators

What does this log?

function* abc() {
  yield "a";
  yield "b";
  return "c";
}
const g = abc();
g.next();
g.next();
console.log(g.next(), g.next());
Question 5 of 5 from: JS Generators

What does this log?

function* nums() {
  let n = 1;
  while (true) {
    yield n++;
  }
}
const out = [];
for (const x of nums()) {
  if (x > 3) break;
  out.push(x);
}
console.log(out);
Ready to submit?

Click a question to go back and check it. After you submit, you will see the right answer and an explanation for every question. As a guest, nothing is saved.