Last active
January 27, 2019 10:34
-
-
Save youaresofunny/22fa6b950836ef93c371dd70ef29afbd 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
function* formGen() { | |
let name, surename, date; | |
nameLabel: | |
while (true) { | |
name = yield('Enter name'); | |
if (name === 'cancel') return; | |
surenameLabel: | |
while (true) { | |
surename = yield('Enter surename'); | |
if (surename === 'back') continue nameLabel; | |
dateLabel: | |
while (true) { | |
date = yield('Enter date'); | |
if (date === 'back') continue surenameLabel; | |
break nameLabel; | |
} | |
} | |
} | |
return { name, surename, date }; | |
} | |
const form = formGen(); | |
const question = form.next(); //Enter your name | |
const question2 = form.next('Anton'); //Enter your surename | |
const question3 = form.next('Lo'); // Enter your birthdate | |
const backQuestion = form.next('back'); // Enter your surename | |
const dateQuestion = form.next('Lopan'); | |
const formData = form.next('01.01.01'); | |
console.log(formData) // Anton Lopan 01.01.01 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment