1//Inside lib file declare functions
2const animalName = (name) => {
3 console.log(name)
4}
5const animalSound = (sound) => {
6 console.log(sound)
7}
8//Export these both as JSON
9module.exports = {animalName, animalSound}
10
11//Navigate to file you want to use them and import
12const animalLib = require('./location_of_file.js')
13
14//To access the function
15animalLib.animalName("zebra")
1function foo() {}
2function bar() {}
3
4// To export above functions:
5module.exports = foo;
6module.exports = bar;
7
8// And in the file you want to use these functions,
9// import them like this:
10const foo = require('./module/path');
11const bar = require('./module/path');
12
13
1module.exports = function(firstParam) { console.log("You did it"); },
2module.exports = function(secondParam) { console.log("Yes you did it"); },
3// This may contain more functions