I started learning NodeJS programming the first thing that I would like to write is to add the two numbers using NodeJS here is the solution. The code is very simple and easy to understand for beginners like me that is new in NodeJS programming.
My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Thank you.
Sample Program Output
Program Listing
sum.js
/* Addition of Two Numbers in NodeJs */
/* July 27, 2017 Thursday 10:41 PM */
/* Written By: Mr. Jake R. Pomperada */
var readline = require('readline');
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
console.log('\n');
console.log('Addition of Two Numbers in NodeJS');
console.log('\n');
rl.question('Enter first value : ', function (x) {
rl.question('Enter second value : ', function (y) {
var a = parseInt(x);
var b = parseInt(y);
var sum = (a+b);
console.log('\n');
console.log('The sum of ',a, ' and ',b, ' is ' , sum,'.');
console.log('\n');
console.log('End of Program');
rl.close();
});
});