index3.js 2.16 KB
Newer Older
sirilak's avatar
sirilak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
// // //console.log('sirilak');
// // //console.log('hello %s', 'world');
// // // Prints: hello world,
// // r.question('กรอกชื่อ', (name) => {
// // r.question('ปีเกิด พ.ศ.', (year) => {
// //----------------------------------------------------------------------------------//
// const rl = require('readline');
// const r = rl.createInterface(input = process.stdin)

//         year = 2561 - year;

//         r.question('ขอเบอร์ด่วน', (phone) => {
    
//             console.log(`คุณ${ name }อายุ${ year } เบอร์ ${phone}.`)
//             r.close()
//         })
//     })
// })  

// //การเรียกชื่อ อายุ เบอร์
// //----------------------------------------------------------------------------------------

// const rl = require('readline');
// let label =['name','year','phon']
// let data=[]
// const r = rl.createInterface(input = process.stdin)
// let i = 1
// r.on('line', (line) => {

//     data[label[i]] = line

//     console.log(`line == ${line} and i = ${i}`)
//     i++;
//     if (i == 3) {

//         console.log('label',label)
//         label[9]='Holy Cow!'
//         console.log('label',label)
//         console.log('data',data)
//         r.close()
//     }
// })
// r.on('close', () => r.close())
// //การเรียกชื่อ บอกจำนวนแถว

// //----------------------------------------------------------------------------
// const readline = require('readline');

// const rl = readline.createInterface({
//   input: process.stdin,
//   output: process.stdout
// });

// rl.question('กรอกชื่อ ', (answer) => {
//   console.log(`สวัสดี: ${answer}`);
//   rl.close();
// });
//-----------------------------------------------------------------------------



const rl = require('readline');
const r = rl.createInterface(input = process.stdin)
let i = 0
let data = []
r.on('line', (line) => {
  data[i]= line
  i++
  if(i == 3) {
      data[1] = 2561-data[1]
    console.log(`สวัสดีคุณ  ${data[0]}  คุณอายุ  ${data[1]} ปี   เบอร์  ${data[2]}`)
    r.close()
  }
})