Let's make a table

It's time for an example. Start by creating a new folder called chapter2/ in your lib/ directory, and then create a blank file in that called table-factory.js. We will not do much directly inside main.js from here on--instead, we will create modules that get loaded by main.js. This allows us to keep our code clean and split it into manageable pieces. Working with modules is a key skill both for organizing your code and reusing useful code you've written--getting into the practice of breaking your project into smaller components is something that will serve you well as you grow as a JavaScript developer.

Since we don't want to play around with HTML inside of our codebase too much, we will write a bunch of functions to build ...

Get D3.js 4.x Data Visualization - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.