Commit 9e3eab27 authored by Natchaya Sripaksee's avatar Natchaya Sripaksee

ส่งการบ้านweek3

parent 738af216
...@@ -18,19 +18,17 @@ ...@@ -18,19 +18,17 @@
const rl = require('readline'); const rl = require('readline');
const r = rl.createInterface(input = process.stdin) const r = rl.createInterface(input = process.stdin)
let i = 1
let label = ['name', 'year', 'phone'] let i = 0
r.on('line', (line) => {
data[label[i] = line let data = []
console.log(`line == ${line} and i=${i}`) r.on('line', (line) => {
i++; data[i]= line
if (i == 3) { //console.log(${label[i]} == ${line} and i = ${i})
console.log('label'.label) i++
console.log('data', data) if(i == 3) {
r.close(); data[1] = 2561-data[1]
} console.log(`สวัสดีคุณ ${data[0]} เบอร์ ${data[2]} คุณอายุ ${data[1]} ปี `)
r.close()
}) }
r.on('close', () => r.close()) })
\ No newline at end of file \ 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