Commit 702bd059 authored by Thanawit Thisanon's avatar Thanawit Thisanon

การบ้าน week03 ขอ2คะแนน

parent 92f0c884
const massage = "Helo world"; const massage = "Helo world";
let name =""; let name = "";
console.info(massage); console.info(massage);
/*const readline = require('readline'); /*const readline = require('readline');
const fs = require('fs'); const fs = require('fs');
......
const readline = require('readline');
const r = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// r.question('กรอกชื่อ :', (name) => {
// r.question('กรอกปีเกิด:', (date) => {
// date = 2561 - date
// r.question('ขอเบอร์ด้วยจ้า:', (Phone) => {
// console.log(`ชื่อ: ${name} อายุ: ${date} เบอร์โทร: ${Phone}`);
// r.close();
// });
// });
// });
let i = 0;
let label = ['name', 'year', 'phone'];
let data = [];
console.log('กรอกชื่อ :');
r.on('line', (line) => {
data[label[i]] = line;
if (i == 0) {
data[label[i]] = line;
console.log('กรอกปีเกิด พ.ศ. :')
i++
} else if (i == 1) {
data[label[i]] = line;
console.log('เบอร์โทร :')
i++
} else if (i == 2) {
data[label[i]] = line;
console.log(`สวัสดีคุณ: ${data['name']} อายุ: ${2561 - data['year']} เบอร์โทร: ${data['phone']} `);
r.close();
}
})
r.on('close', () => r.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"
},
"keywords": [
"homework03"
],
"author": "thanawit",
"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