Commit c99bfdbe authored by Piyunggur Sonsongklin's avatar Piyunggur Sonsongklin
parent 06c49de2
const rl = require('readline');
const io = rl.createInterface({
input:process.stdin,
output:process.stdout
});
// io.question('กรอกชื่อ ', (name,what) => {
// io.question('ปีเกิด พ.ศ ', (year) => {
// year = 2561 - year;
// io.question('ขอเบอรโทรด่วน ', (phone) => {
// console.log(`คุณ ${name} อายุ ${year}.`);
// io.close();
// });
// });
// });
// var i = 0;
// var name = ""; var year =""; var phone= "";
// io.on('line',(line)=>{
// if(i == 0){
// name = line;
// }else if(i == 1){
// year = line;
// }else{
// phoen = line;
// console.log('you '+ name + ' your old ' + (2561-year) + 'and your phone ' + phone);
// io.close();
// }
// i++;
// });
// io.on('close',()=>io.close());
var i = 0;
var input = [];
var type = ['name','year','phone'];
io.on('line',(line)=>{
input.push(line);
if(i == 2){
// var year = parseInt(input[1]);
console.log('สวัสดีคุณ '+ input[0] + ' เบอร์ ' + input[2] + ' อายุ ' + (2561-parseInt(input[1])) +' ปี');
io.close();
}
i++;
});
\ 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"
},
"author": "",
"license": "ISC"
}
const http = require('http')
http.createServer((req, res) =>{
res.writeHead(200,{'Content-type':'text/html'});
res.end();
});
\ 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