Making Asteroid Dodger with JavaScript and HTML5 Canvaswith Ted Zhu

Keep Track of Score

Open main.js in your code editor, and add the following lines of code as indicated in yellow to enable score tracking:

File: main.js

Now add the following line of code in bullet.js so that we can have the score increase when we hit asteroids:

File: bullet.js

If you made the code modifications correctly, you should be able to see score and high score working:

Debugging Tips

Debugging Tips

  • All JavaScript code is case-sensitive. Make sure that every letter of your code matches the casing as seen in the instructions.
  • Keep an eye out for all symbols such as parenthesis, periods, commas, quotations, and semicolons.
  • The semicolon at the end of every JavaScript statement is the easiest symbol to forget.

Note about whitespace:

For the most part, JavaScript doesn't care about whitespace (spaces, tabs, and carriage returns). In fact, it's actually encouraged for you to use as many spaces, tabs, and carriage returns as necessary to make your code easy to read. For example:

Without Whitespace
With Whitespace

Which is easier to read?

×