Module.exports, objects


#1

How does this code work?

let Menu = {};

module.exports = {
  specialty: "Roasted Beet Burger with Mint Sauce",
  getSpecialty: function() {
    return this.specialty;
  } 
};

Some file:

const Menu = require('./ifyouseme,hi.js');

console.log(Menu.getSpecialty());

How do specialty and getSpecialty get assigned to Menu?


#2

Please post a link to the exercise. Thanks.


#3

Sorry if this has been resolved, but if not, I might be able to offer some help. The specialty and getSpecialty are both assigned to the ‘const Menu’ in the second file, which is completely separate from the ‘let Menu’ created in the first .js file.

My question to anyone else reading (or even the OP if you know) is what is the point of creating the first ‘let Menu’ object if you’re just going to export a separate object (module.exports = {yourObject};).