0%

A hands-on, practical Introduction to coding!

Do you want to learn to code? Perhaps you want to learn how to build the next social media sensation or blockbuster game? Or perhaps you just want to get some valuable coding experience under your belt? This easy-to-follow, practical, and fun guide is the perfect place to start on your coding journey. You'll be learning to program with JavaScript - the most popular programming language on Earth. And it runs in web browsers, making it particularly suited to creating web-based apps and games. But the principles and techniques that you'll learn will provide you with a foundation to go on and learn many other languages, too.

You'll learn:

  • Programming basics, including data types, variables and more
  • How to use logic to control the flow of a program
  • How to use loops to repeat code over and over again
  • How to write functions that can be used to store code in reusable blocks
  • How to store data in collections such as arrays, sets and maps
  • How to create objects that store properties and actions
  • And much more!

Along the way, you'll build a collection of fun applications, including games and interactive web pages. Start learning to code today!

Table of Contents

  1. Learn to Code with JavaScript
  2. Notice of Rights
  3. Notice of Liability
  4. Trademark Notice
  5. About SitePoint
  6. About Darren Jones
  7. Preface
    1. Who Should Read This Book?
    2. Conventions Used
    3. Supplementary Materials
  8. Chapter 1: Press Start
    1. Programming
    2. A Brief History of Programming
    3. JavaScript
    4. Hello, World! Your First JavaScript Program
    5. JavaScript in the Browser
    6. I Can Code a Rainbow: Your Second JavaScript Program
    7. A Programmer’s Mindset
    8. Challenges
    9. Summary
  9. Chapter 2: Programming Basics
    1. Comments
    2. Programming Grammar
    3. Variables
    4. Pop-up Interaction
    5. Challenges
    6. Summary
  10. Chapter 3: Letters and Words
    1. Chars and Strings
    2. Template Literals
    3. Challenges
    4. Summary
  11. Chapter 4: Numbers
    1. Integers and Floats
    2. Numeric Literals
    3. Exponential Notation
    4. When Is a Number Not a Number?
    5. Arithmetic Operations
    6. Varying Variables
    7. Increments
    8. How Old?
    9. Calculations with Numbers and Strings
    10. Converting Between Strings and Numbers
    11. Random Numbers
    12. More Methods
    13. Challenges
    14. Summary
  12. Chapter 5: Collections
    1. Arrays
    2. Arrays in JavaScript
    3. Multi-dimensional Arrays
    4. Challenges
    5. Summary
  13. Chapter 6: Logic
    1. Booleans
    2. Logical Operators
    3. Comparison
    4. Flow Control
    5. What’s Your Favorite Animal?
    6. Rock Paper Scissors
    7. Challenges
    8. Summary
  14. Chapter 7: Going Loopy
    1. What’s a Loop?
    2. Infinite Loops
    3. While Loops
    4. Do–while Loops
    5. For Loops
    6. Nested Loops
    7. Challenges
    8. Summary
  15. Chapter 8: Functions
    1. Functions in JavaScript
    2. Return Values
    3. Parameters and Arguments
    4. Callbacks
    5. Choosing the Right Type of Function
    6. Challenges
    7. Summary
  16. Chapter 9: Objects
    1. Properties and Methods
    2. Creating Objects in JavaScript
    3. Properties and Methods
    4. this
    5. Roll the Dice
    6. Challenges
    7. Summary
  17. Chapter 10: The Document Object Model
    1. The Document Object Model
    2. Getting an Element
    3. Updating the HTML
    4. Getting Multiple Elements
    5. Navigating the DOM Tree
    6. Creating Dynamic Markup
    7. Getting and Setting Attributes
    8. Doing It with Style
    9. A Simple To-do List
    10. Challenges
    11. Summary
  18. Chapter 11: The Main Event
    1. Event-based Programming
    2. Click Events
    3. Forms
    4. Keyboard Events
    5. Mouse Events
    6. Simple To-do List
    7. Challenges
    8. Summary
  19. Chapter 12: Going Loopy Over Arrays
    1. Spreading Strings
    2. Array Iteration Methods
    3. Find
    4. Every
    5. Iterating over Objects
    6. To-do List Project
    7. Challenges
    8. Summary
  20. Chapter 13: Let’s Get Functional
    1. Named Parameters
    2. The Rest Parameter
    3. Recursive Functions
    4. Scope
    5. Hoisting
    6. Functions That Return Functions
    7. Closures
    8. Functional Programming
    9. Pure Array Updates
    10. Challenges
    11. Summary
  21. Chapter 14: Getting Classy
    1. Copying Objects in JavaScript
    2. Object-oriented Programming
    3. Classes
    4. Classy Components
    5. The Pet Unicorn Game
    6. Challenges
    7. Summary
  22. Chapter 15: It’s About Time
    1. The UNIX Epoch
    2. Times and Dates
    3. Timing Functions
    4. Asynchronous Programming
    5. Intervals
    6. Animation
    7. Cookie Grabber Game
    8. Challenges
    9. Summary
  23. Chapter 16: End Of Line
    1. Coding Best Practice
    2. Going Further with JavaScript
    3. Learn Another Language
    4. Always Learning
    5. Carry On Coding
    6. Internet of Things
    7. Challenges
    8. Summary
3.128.203.143