-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.js
More file actions
40 lines (32 loc) · 880 Bytes
/
node.js
File metadata and controls
40 lines (32 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const questions = [
"O que aprendi hoje?",
"O que me deixou aborrecido? e o que eu poderia fazer para melhorar?",
"O que me deixou feliz hoje?",
"Quantas pessoas eu ajudei hoje?",
]
const ask = ( index = 0) => {
process.stdout.write(`\n\n${questions[index]}\n`)
}
ask()
const answers = []
process.stdin.on("data", data => {
answers.push(data.toString().trim())
if (answers.length < questions.length) {
ask(answers.length)
} else {
process.exit()
}
})
process.on("exit", () => {
console.log(`
Você respondeu as seguintes perguntas:
O que você aprendeu hoje?
${answers[0]}
O que te aborreceu hoje e você poderia melhorar foi:
${answers[1]}
O que te deixou feliz hoje:
${answers[2]}
Quantas pessoas você ajudou hoje:
${answers[3]}
`)
})