Commit 10cc946e authored by jatuporn Tonggasem's avatar jatuporn Tonggasem

การบา้น03

parent 8766374a
const MESSAGE = "Hello Word" ;
console.info(MESSAGE);
console.info("Hello Word");
/*const readline = require('readline');
const fs = require('fs');
const rl = readline.createInterface({
input: fs.createReadStream('package.json'),
crlfDelay: Infinity
}
);
rl.on('line',(line) => {
//พฤติกรรมของฟังก์ชัน
console.log('ผู้ใช้กรอกข้อมูลแล้วจ้า :'+ line );
});
rl.on('close',()=>{
console.log('ไม่มีบรรทัดเหลือให้อ่านแล้ว');
});*/
/////////////////////////////week 03
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
/*rl.question('กรอกชื่อ:', (answer) => {
rl.question('กรอกปีเกิด:',(year)=>{
year= 2561-year
rl.question('กรอกเบอร์ติดต่อ:', (phone)=>{
console.log(`สวัสดีคุณ: ${answer} อายุ:${year}เบอร์:${phone}` );
rl.close();
})
})
});*/
////////////////////////////
/*
let i = 1
rl.on('line',(line)=>{
rl.on('line',(year)=>{
rl.on('line',(phone)=>{
console.log(`Name == ${line} Year==${year} Phone==${phone} and =${i}`)
i++
if(i==3){
rl.close()
}
})
})
})
rl .on('close',() => rl.close())
*/
///////////////////////
/*
let i = 0
let label = ['Name','Year','Phone']
let data = []
rl.on('line',(line)=>{
data[label[i]]=line
console.log(`${label[i]}=${line}`)
i++
if(i==3){
console.log('ชื่อ:',label)
label[9] = 'Holt Cow!'
console.log('label',label)
console.log('data',data)
r.close()}
})
*/
/*rl.question('กรอกชื่อ',(name)=>{
rl.question('กรอกวันเกิด,' ,(year)=>{
year = 2561-year
rl.question('ขอเบอรืโทร' , (phone)=>{
console.log(คุณ ${name} อายุ ${year} เบอร์ ${phone});
rl.close();
});
});
});*/
let i = 1
console.log('กรอกชื่อ:')
let name
let year
let phone
rl.on('line',(line) =>{
if(i==1){
name = line
i++
}else if (i==2){
year = 2561- line
i++
}else if (i==3){
phone = line
console.log(`สวัสดีคุณ ${name} อายุ ${year} เบอร์ ${phone}`);
rl.close();
}
})
{
"name": "week3",
"version": "1.0.0",
"description": "การบ้านสัปดาห์ที่ 3",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"homework",
"03"
],
"author": "5711405317",
"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