Created
May 27, 2021 16:13
-
-
Save lxhom/45e53c93323039068d3651a259b6d0b4 to your computer and use it in GitHub Desktop.
just a simple demo for async in for loops
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
let { Toggle } = require("enquirer") | |
let main = async () => { | |
let questions = ["Are you 18 or older?", "Do you agree to your data being shared with 3rd parties?", "Do you" + | |
" accept our ToS?"]; | |
let answers = {enabled: "Yes", disabled: "No"} | |
let values = [] | |
for (let question of questions) { | |
values.push(await new Toggle({ | |
message: question, | |
...answers | |
}).run()) | |
} | |
console.log("Access", values.reduce((a, b) => a && b) ? "granted" : "denied") | |
} | |
// noinspection JSIgnoredPromiseFromCall | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment