# JavaScript: Generator function example

```
function* gen()  
{  
  yield 100;  
  let a = 100
  a = a + 1
  yield a;
  a = 200
  yield a * 2;
}
 
// Calling the Generator Function  
var mygen = gen();  
console.log(mygen.next().value);
console.log(mygen.next().value);
console.log(mygen.next().value);
``` 


```
Output:
100
101
400
``` 

[Execute above code here](https://onecompiler.com/javascript/3xpce6xp9)


