Commit 1cdb3b61 authored by Supharoek Sudadet's avatar Supharoek Sudadet

การบ้านที่3

parent add6e93a
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
/*
rl.question('ใส่ชื่อของคุณ :', (name) => { // TODO: ใส่ชื่อของคุณ
rl.question('ใส่ปีเกิดของคุณ :', (year) => { // TODO: ใส่วันเกิดของคุณ
year = 2561 - year
console.log(`สวัสดีคุณ : ${name} คุณอายุ : ${year}`);
rl.close();
});
});
*/
let i = 0
let label = ['สวัสดี','อายุ','เบอร์โทร']
let data = []
rl.on('line', (line) => {
data[i] = line
//console.log(`${label[i]} == ${line} and i = ${i}`)
i++
if (i == 3) {
// ต้องพิมพ์อะไรไหม?
data[1] = 2561-(parseInt(data[1]))
console.log(label[0]+": "+data[0]+", "+label[1]+": "+data[1]+", "+label[2]+": "+data[2])
rl.close()
}
})
rl.on('close', () => rl.close() )
{
"name": "week03",
"version": "1.0.0",
"lockfileVersion": 1
}
{
"name": "week03",
"version": "1.0.0",
"description": "การบ้่านสัปดาที่ 3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "http://projectcs.sci.ubu.ac.th/professorj/nodejs-60-2.git"
},
"keywords": [
"homework03"
],
"author": "5811403839",
"license": "ISC"
}
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