Created
March 17, 2021 04:07
-
-
Save ashwinkumar2438/7a06420ca8568a3cbfbd59f6f68ec2f6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function* addGen(sum){ | |
let first= yield sum; | |
sum+=first; | |
let second=yield sum; | |
sum+=second; | |
return sum; | |
} | |
let addwith=addGen(40); | |
console.log(addwith.next()); //@yields {value: 40, done: false} | |
console.log(addwith.next(40)); //@yields {value: 80, done: false} | |
console.log(addwith.next(20)); //@returns {value: 100, done: true} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment