showing results for - "javascript generator function"
Marissa
21 Nov 2020
1function* idMaker() {
2  var index = 0;
3  while (true)
4    yield index++;
5}
6
7var gen = idMaker();
8
9console.log(gen.next().value); // 0
10console.log(gen.next().value); // 1
11console.log(gen.next().value); // 2
12console.log(gen.next().value); // 3
13// ...
Klara
02 Jan 2021
1
2function* expandSpan(xStart, xLen, yStart, yLen) {
3    const xEnd = xStart + xLen;
4    const yEnd = yStart + yLen;
5    for (let x = xStart; x < xEnd; ++x) {
6         for (let y = yStart; y < yEnd; ++y) {
7            yield {x, y};
8        }
9    }
10} 
11
12
13//this is code from my mario game I dont think this code is functional
Alexander
22 Nov 2017
1function* name([param[, param[, ... param]]]) {
2   statements
3}
4