Course 201 Class Ten “Debugging”
Types of error
Generally speaking, when you do something wrong in code, there are two main types of error that you’ll come across:
- Syntax errors: These are spelling errors in your code that actually cause the program not to run at all, or stop working part way through — you will usually be provided with some error messages too. These are usually okay to fix, as long as you are familiar with the right tools and know what the error messages mean!
- Logic errors: These are errors where the syntax is actually correct but the code is not what you intended it to be, meaning that program runs successfully but gives incorrect results. These are often harder to fix than syntax errors, as there usually isn’t an error message to direct you to the source of the error.
Okay, so it’s not quite that simple — there are some other differentiators as you drill down deeper. But the above classifications will do at this early stage in your career. We’ll look at both of these types going forward.
Questions
-
Name some key differences between a Syntax Error and a Logic Error.
A syntax error is in the syntax of the sequence of characters that was intended to be written, but a logical error causes a program to act incorrectly but not quit running.
-
List a few types of errors that you have encountered in past lab assignments and explain how you were able to correct them.
I had a logical errors that kept my total from displaying as a number it displayed as NaN because I had an extra space coding characters.
-
How will this topic continue to influence your long term goals?
I think debugging code will be key to almost everybodys longterm goals as we will need to be able to fix our own and others mistakes.
-
How would you describe the JavaScript Debugger tool and how it works to someone just starting out in software development?
The debugger tool will show you where the code is broken by line and examine the variables as it runs.
-
Define what a breakpoint is.
A breakpoint is where the code stops because it is wrong.
-
What is the call stack?
It is used in Javascript to keep track of all the function calls in a program that we are running. This is an internal process.
Resources
What went wrong? Troubleshooting JavaScript
What are browser developer tools?