Create your own module in Nodejs

Exports

exports.myDateTime = function () {
return Date();
};
function getPlus(a, b) {
return a + b;
}
function getMultiply(a, b) {
return a*b;
}
exports.getPlus = getPlus;exports.getMultiply = getMultiply;
const getName = () => {
return ‘Skywalker’;
}
const getOrigin = () => {
return ‘Tatooine’;
}
exports.getName = getName;exports.getOrigin = getOrigin;

Module.exports

function getPlus(a, b) {
return a + b;
}
function getMultiply(a, b) {
return a*b;
}
module.exports = {getPlus,getMultiply}
var dt = require(‘./myfirstmodule’)
.
.console.log(‘Current date and time : ‘ + dt.myDateTime());.

--

--

Software engineering and film. All are work-in-progress.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store