Skip to content

Instantly share code, notes, and snippets.

View SarveshKadam's full-sized avatar
🏠
Working from home

Sarvesh Kadam SarveshKadam

🏠
Working from home
View GitHub Profile
// - - Main file[main.js] - - 
const add = require('./calculate')
const result = add(5,8)
console.log(result) //Output : 13
// - - Exported file [calculate.js] - - 
const add = {
 result : (a,b)=>{
 return a + b
 }
}
module.exports = add.result
// - - Main file[main.js] - - 
const add = require('./calculate')
const result = add.result(5,8)
console.log(result) //Output : 13
// - - Exported file [calculate.js] - - 
const add = {
 result : (a,b)=>{
 return a + b
 }
}
module.exports = add
// - - - Main File[main.js] - - 
const add = require('./calculate') //name of the desired file
const result = add(2,4)
console.log(result); //Output : 6
// - - Exported file [calculate.js] - - 
const add = (a,b)=>{
 return a + b
}
module.exports = add