Preview:
// Returns addition of two numbers exports.add = function (a, b) { return a+b;
};
// Returns difference of two numbers exports.subtract = function (a, b) { return a-b;
};
// Returns product of two numbers exports.multiply = function (a, b) { return a*b;
};
moduleExample.js
var calculator = require('./calculator'); var a=10, b=5;
console.log("Addition : "+calculator.add(a,b)); console.log("Subtraction : "+calculator.subtract(a,b)); console.log("Multiplication : "+calculator.multiply(a,b));\

downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter