Unable to export module in another file in nodejs

I am trying to create some dummy function in nodejs and trying to export it in another file but when I am running it using node index.js it might some sort of silly mistake but its showing error that:

TypeError: spr.comb is not a function

Below is my code:

spread.js

const comb = () => {
   const arr = [4,5,6];
   const newArr = [1,2,3,...arr];
   console.log(newArr);
}

module.exports = comb;

index.js

const spr =  require('./spread');
spr.comb();  

Someone let me know what I am doing wrong.

Answer

Problem is that you have completely overwritten the module.exports object.

module.exports is an empty object to which you can add the values to export from a module.

In your case, you have re-assigned the module.exports to comb function. So, to call the function, change

spr.comb(); 

to

spr(); 

For spr.comb() to work, you need to export the comb function as shown below:

module.exports.comb = comb;

or

exports.comb = { ... }