Topics: Hello Modules Module.exports I, require(), module.exports II, export default, import, Named Exports, Named Imports, Export Named Exports, Import Named Imports, Export as, Import as, Combining Export Statements, Combining Import Statements
-
Copy and Paste your folder from project M1 here
-
You have this folder structure
- your-name
-
- src
-
- prod
-
Create a file named
food.jsin src folder. -
Define array
foodthere and enter these items there:
Saffron.
Kale.
Clementine.
Peaches.
Nori.
Kobe.
Olive.
Rosemary.
-
Export it as
food -
Edit src/index.js to require
food.jsmodule and printfoodinto console. -
Export a function named
getSpecialsinfood.jsto filter foods that start withNor end witheor at least have onerin their name. -
Use that function in the
src/index.jsand log into console. -
Define
menu.jsand define a class namesmenuand export default using ES sytanx. -
Fill
itemsarray as property in the class and fill it through constructor. -
Add method
getAllto show all items. -
Import this class in
src/index.jsand make a new object and enter some menu items as parameter. -
Print all menu items through
getAllfunctions. -
Add a named export to
menu.jsasgetVegfunction. -
This function return an arrays of 3 vegeterian foods.
-
Use this named export in
src/index.jsand log foods into console.
Send Pull Request. Check how to deliver your code: https://codingwithbasir.com/how-to-deliver-projects/
Download Learn JavaScript eBook from https://codingwithbasir.com/learn-javascript
