index.js
exports the node js module
const mod = require("./mod");
console.log(mod.sum([3,3]));
console.log(mod.name);
console.log(mod.gender);
console.log("index file here");
mod.js
console.log("Module file here");
function sum(arr){
addition = 0;
arr.forEach(element => {
addition += element;
});
return addition;
}
module.exports = {
sum:sum,
'name':'vishal',
'gender':'male'
};
Thanks you for commenting your questions. I will see question and respond you.