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 rl = require('readline');
const r = rl.createInterface({
input: process.stdin,
output: process.stdout
});
/*var yearday = 2561;
r.on('line', (line) => {
r.question('ชื่อของคุณ : ', (name)=>{
r.question('ปีเกิด พ.ศ. ', (year)=> {
r.question('เบอร์โทร : ', (phone) => {
year = yearday - year;
console.log(`ชื่อ == ${name}. ปี == ${year}. เบอร์โทร == ${phone}.`);
r.close();
})
});
});
});
*/
let i = 0
r.on('line',(line) =>{
if(i==0){
name = line
i++
}else if (i==1){
age = line
i++
}else if (i==2){
console.log(`สวัสดีคุณ ${name} อายุ ${2560-age} เบอร์ ${line}`);
r.close();
}
})
/*
const http = require('http');
http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World!');
console.log('client connected.')
}).listen(8080);
*/