// Practice Set · JS Iterations · guest

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

Question 1 of 5 from: JS Loops

What does this log?

const found = [];
for (const n of [4, 8, 15, 16]) {
  if (n > 10) break;
  found.push(n);
}
console.log(found);
Question 2 of 5 from: JS Loops

for (const i = 0; i < 3; i++) { } throws a TypeError.

Question 3 of 5 from: JS Iterables

What does this log?

const s = "hi\u{1F600}";
console.log(s.length, [...s].length);
Question 4 of 5 from: JS Iterators

What does this log?

const range = {
  from: 1,
  to: 3,
  [Symbol.iterator]() {
    let current = this.from;
    const last = this.to;
    return {
      next() {
        if (current <= last) {
          return { value: current++, done: false };
        }
        return { value: undefined, done: true };
      }
    };
  }
};
console.log([...range], [...range].length);
Question 5 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());
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.