Commit 738af216 authored by Natchaya Sripaksee's avatar Natchaya Sripaksee

ขอ2คะแนน

parent 96d8310e
// const rl = require('readline');
// const r = rl.createInterface(input = process.stdin)
// r.question('กรอกชื่อ',(name) => {
// r.question('ปีเกืด พ.ศ. ',(year)=>{
// year = 2561 - year
// r.question('ขอเบอร์ด่วน',(phone)=>{
// console.log(`คุณ ${name} อายุ ${year} เบอร์ ${phone}.`)
// r.close()
// })
// })
// })
//---------------------------------------------------------------------------------
const rl = require('readline');
const r = rl.createInterface(input = process.stdin)
let i = 1
let label = ['name', 'year', 'phone']
r.on('line', (line) => {
data[label[i] = line
console.log(`line == ${line} and i=${i}`)
i++;
if (i == 3) {
console.log('label'.label)
console.log('data', data)
r.close();
}
})
r.on('close', () => r.close())
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment