When you’re done with this chapter, you will

  • Understand a super-powerful tool (functions) for programmers
  • Be able to tell stories and calculate things with functions
  • Build 100 planets and fly among them

Chapter 5Functions: Use and Use Again

Computer programs are a little like stories.

Once upon a time, there were 100 special planets. Each planet was a different color and a different size. They were scattered throughout known space. And there was only one ship fast enough—and one pilot crazy enough—to reach them all.

By now, we have some of the know-how needed to write that story in JavaScript code. But where do we start? How could we organize all that? Are we really going to have to type all the code for 100 planets?

The programming answer ...

Get 3D Game Programming for Kids, 2nd 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.