0

Sorry if the title doesn't make sense, I'm not sure how to explain it myself.

Basically What I want is among the lines of this:

const myFile = require('./myFile')

const schematic = myFile.model('Name', [1,2,3])

const addValues = schematic.add()

console.log(addValues)

And it should output 6 since 1+2+3 is 6.

Im not sure how to construct the file to do this.

This is my myFile.js file:

module.exports.model = (name,values) => {
    // code here
    return this
}

module.exports.model.add = (name,vales) => {
    // Adding code
    return addedNumbers
}

I'm relatively new to NodeJS so I don't have any experience doing this.

iVizWiz
  • 3
  • 2
  • Your `add` function is built to receive two parameters in `myFile.js` but when you call it in the consuming module, you do not pass any argument to it – orimdominic Nov 16 '22 at 23:01
  • This has nothing to do with node modules and exporting. Get your code working in a single file first. Then we can talk about how to put parts of it in another module. – Bergi Nov 17 '22 at 00:05

0 Answers0