WEB DEVELOPMENT PROJECT PRACTICE BACK END
Creating Custom Modules in Node Using NodeJs....
index.js
Code...
const mod = require("./mod");
// const average = require("./mod");
// console.log(mod.name);
console.log(mod.avg([3,7]));
console.log(" This is index.js");
console.log(" This is mod.js");
function average(arr){
let sum=0;
arr.forEach(element => {
sum+= element;
});
return sum/arr.lenght;
}
module.exports= {
avg: average,
name: "shohaib",
repo: "github"
}
// module.exports.name="shohaib";
No comments