# Iterator

```javascript
function* myIterator(start = 0, end = Infinity, step = 1) {
    let n = 0;
    for (let i = start; i < end; i += step) {
        n++;
        yield i;
    }
    return n;
}

for (let item of myIterator(0, 10)) {
    console.log(item)
}

let it = myIterator(0, 10);
let item = it.next();
while (!item.done) {
    console.log(item.value);
    item = it.next();
}
```