Skip to content

Instantly share code, notes, and snippets.

View sauravdroid's full-sized avatar

Saurav Biswas sauravdroid

View GitHub Profile
@sauravdroid
sauravdroid / passing-values-to-generators.js
Created February 9, 2022 09:00 — forked from ericelliott/passing-values-to-generators.js
Passing values into generators through `.next()`
function* crossBridge() {
const reply = yield 'What is your favorite color?';
console.log(reply);
if (reply !== 'yellow') return 'Wrong!'
return 'You may pass.';
}
{
const iter = crossBridge();
const q = iter.next().value; // Iterator yields question
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;