Commit 238ca4dc authored by winai buttasart's avatar winai buttasart

การบ้าน 3

parent e0ddf37b
const readline = require('readline');
let dateNow = new Date().getFullYear() + 543;
let name, year, tel;
const io = readline.createInterface({
input: process.stdin,
output: process.stdout
});
let count = 0;
let data = {};
console.log('กรอกชื่อ : ');
io.on('line', (line) => {
switch (count) {
case 0:
data['name'] = line;
count++;
console.log('กรอกปีเกิด(พ.ศ.) : ');
break;
case 1:
data['year'] = line;
count++;
console.log('กรอกเบอร์โทร : ');
break;
case 2:
data['tel'] = line;
data['old'] = dateNow - data.year;
io.close();
console.log();
// console.log(data);
console.log('สวัสดีคุณ : ' + data.name);
console.log('เบอร์โทร : ' + data.tel);
// console.log('ปีเกิด : ' + data.year);
console.log('อายุ : ' + data.old + ' ปี');
break;
}
});
io.on('close', () => io.close());
\ No newline at end of file
{
"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://cs.sci.ubu.ac.th/b/Zt7yXa96XFPGXhvrg/node-js-60-2"
},
"keywords": [
"homework",
"03"
],
"author": "5811403796",
"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