This one is intentionally tricky.
function range(start, end) {
return {
[Symbol.iterator]() {
let i = start;
return {
next() {
if (i < end) return { value: i++, done: false };
return { done: true };
}
};
}
};
}
const iter = range(1, 4)[Symbol.iterator]();
const arr = [...iter];
console.log(arr.join(','));
Reply with what is broken and how you would fix it.
VaultBoy ![]()