nic_training
Version:
Sample demos for training on nodejs
35 lines (25 loc) • 804 B
JavaScript
//FirstExample.js
/*In order to obtain the latest Node.js version the correct repository should be added first:
sudo apt-get install nodejs
sudo apt-get install npm->can do it later...
node --version
node*/
//Once the node is installed in the machine, U could open any terminal and start using it.
function addFunc(v1, v2){
console.log("v1 + v2 = " + (v1+v2));
}//Create the function...
var math = function(){
this.addFunc = function(a,b){
return a +b;
}
this.subFunc = function (a, b) {
return a -b;
}
this.mulFunc = function (a, b) {
return a * b;
}
}
addFunc(123,234);//call the function here...
var calc = new math();
console.log("The added value is " + calc.addFunc(123, 234))
console.log("The subtracted value is " + calc.subFunc(123, 234))