function * generator(k){ console.log('begin'); var x = yield k; console.log('x:',x); var y = yield x+k; console.log('y:',y); return x+y+k; } var o = generator(1); var r = o.next(); console.log('1:'+r.value, 'done:'+r.done); r = o.next(3); console.log…