Sample Video Frame

Created by Zed A. Shaw Updated 2024-11-15 13:50:32
 

13: Modules

In Exercise 10 and Exercise 12 you used const fs = require('fs') to use the "file system (fs)" module. A module is just a way to add a feature, or capability, to your own code. Usually a module is code someone else wrote that you want to use, like the fs module. In this exercise you'll learn how to create your own module and require it. Doing this will teach you more about how modules and require works.

For this exercise you will make two files: code.js and geometry.js. You'll put both files in the same directory so that you can access them. To test that you've done this right, type cat code.js then cat geometry.js to view the two files. If you don't see both, then you did it wrong.

Previous Lesson Next Lesson

Register for Learn JavaScript the Hard Way

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.