Tuesday, May 11, 2021

Node Slip3 Solution

 Slip 3 

Create  a  Node.js  Application  that  uses  user  defined  module circle.js which  exports  the functions area () and circumference () and display the details on console.

// circle.js

var PI = Math.PI;
 
exports.area = function (r) {
  return PI * r * r;
};
 
exports.circumference = function (r) {
  return 2 * PI * r;
};


//areacircle.js

var circle = require('./circle.js');

console.log( 'The area of a circle of radius 3 is ' + circle.area(3));

console.log( 'The circumference of a circle of radius 3 is '

      + circle.circumference(3));


/* Output*/


C:\Users\NEW\nodex>node areacircle.js

The area of a circle of radius 3 is 28.274333882308138

The circumference of a circle of radius 3 is 18.84955592153876





No comments:

Post a Comment

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...