fork download
  1.  
  2. function sequence(start=0, step=1) {
  3.  
  4. var counter = start-step;
  5.  
  6. return function(step){
  7. return counter+step;
  8. };
  9. }
  10. var generator = sequence(10, 3);
  11. var generator2 = sequence(7, 1);
  12.  
  13. console.log(generator()); // 10
  14. console.log(generator()); // 13
  15.  
  16. console.log(generator2()); // 7
  17.  
  18. console.log(generator()); // 16
  19.  
  20. console.log(generator2()); // 8
Runtime error #stdin #stdout #stderr 0.01s 29832KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog.js:13:0 ReferenceError: console is not defined