New JavaScript Debugging Exercises

We are happy to announce that Launch School has added two new sets of debugging exercises to our ‘JavaScript Language Fundamentals’ and ‘JavaScript Small Problems’ exercises, both of which are part of our JavaScript fundamentals course — Computational Thinking and JavaScript Programming.

Why Debugging Exercises?

You may be wondering what the value is in solving debugging exercises. What are they and how do they help you learn?

Launch School’s debugging exercises provide some existing code such as a function or a small program, as well as information about the intended behavior of the code. Sometimes the provided code raises an exception; often the bug is more insidious. The student’s task is to hunt down the bug and use their knowledge of core JavaScript concepts to implement a fix.

One obvious benefit of solving this type of exercise is gaining experience picking apart code that someone else has written. Many student programmers spend a large amount of time with their own code, but very little time reading and working with existing code written by others. Being able to read and understand others’ code is an invaluable skill when you get your first programming job and must work on a team, or when you want to make your first open-source software contribution.

Just like the rest of Launch School’s core curriculum, our JavaScript debugging exercises aim primarily to strengthen students’ mastery of the fundamentals. The lure of popular JavaScript frameworks is tempting, and many beginning programmers become distracted by the idea of building something exciting with the latest framework before investing the time to gain a true mastery of the language itself. This mindset leaves beginners vulnerable to common pitfalls and JavaScript ‘gotchas’, which may ultimately result in buggy code that is both frustrating and difficult to fix. Launch School’s debugging exercises provide an opportunity for hands-on experience encountering and correcting these common pitfalls, so that students may gain a deeper understanding of the JavaScript language and avoid such problems in their own code.

Let’s examine some very brief code samples.

Do you know how the output of the following two code snippets will differ? Can you explain why?

There is a bug in the below code preventing the factors of 18 from being displayed accurately. Can you spot it?

Even those who have prior programming experience in another language should take time to familiarize themselves with the particulars of JavaScript when they first begin to use it. Take a look at the two code snippets below. Notice that the identical code on line 3 of each snippet returns true in Ruby, but false in JavaScript.

The above examples touch on basic concepts that any aspiring JavaScript whiz should master before adding layers of abstraction such as libraries and frameworks to their code. A true mastery of the JavaScript language allows you to understand the why behind a program’s unexpected behavior, and to address the issue in your code logically and with purpose. Conversely, gaps in one’s knowledge of the fundamentals will likely lead to buggy code and a great amount of frustration as the developer attempts to figure out how to fix the problem without truly understanding why the problem occurred in the first place. Mastery of the fundamentals may require a bit more time initially, but it will pay off in spades as your ability to tackle larger and more complex problems with clean, maintainable code advances.

Learn More

If you’re new to Launch School and want to learn more, take some time to read about why we focus on Mastery-Based Learning. Registered members of the Launch School community can view all of our JavaScript exercise sets at launchschool.com/exercises.