Slip 29 - A) Create Node js application using user defined Rectangle module to find area of rectangle and display the details on console.

Solution:

rect.js          

var rect={ 

  area: function(l,b)

{

    var a; 

     a=l*b;

 

  console.log('area of rectangle is:'+a);

}

};

 module.exports=rect

 

myrect.js

var mymod=require('C:/Users/Public/node_prog/rect.js');

mymod.area(5,4);

 


Initiate myrect.js file :

C:\Users\Your Name>node myrect.js

Post a Comment

0 Comments