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.

The Geometry Code

Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.

Still Not Sure? Check out more curriculum!