8. importing / create module

01
Create a new file in the same directory, with function to export as an object with
module.exports
this example contains math functions in math.js
const add = (a,b) => a + b const subtract = (a,b) => a - b const multiply = (a,b) => a * b const divide = (a,b) => a / b module.exports = {add,substact,multiply,divide}

02
Import them into the server with require('./')
you must use specific path when not using Common Core Modules.
You do not need .js
const math = require('./math') console.log(math.add(4,7)) console.log(math.multiply(3,5))