Skip to content

Commit 7592c8c

Browse files
committed
1-stdin.js file
1 parent 66cadd4 commit 7592c8c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

0x05-Node_JS_basic/1-stdin.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
process.stdin.setEncoding('utf8');
2+
3+
console.log('Welcome to Holberton School, what is your name?');
4+
5+
process.stdin.on('data', (input) => {
6+
const name = input.trim();
7+
8+
if (name.length > 0) {
9+
console.log(`Your name is: ${input}`);
10+
process.exit();
11+
}
12+
});
13+
14+
process.stdin.on('exit', () => {
15+
process.stdout.write('This important software is now closing\n');
16+
});

0 commit comments

Comments
 (0)