Created
December 28, 2017 18:46
-
-
Save lucasmenendez/4c3ffdae287ecbbc704945f0971fd7da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const base = 5; | |
function *sum(num) { | |
let result = num + base; | |
num = yield(result); | |
return (result + num); | |
} | |
let it = sum(16); | |
console.log(it.next()); // {"value":21,"done":false} | |
console.log(it.next(12)); // {"value":33,"done":true} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment