Week 5 Outline
- Discuss Assignment 4
- Discuss debugging strategies
- Types of errors
- Syntax error occurs when page loads, usually a typing error
- Run-time error occurs when a statement is executed
- Logic error causes incorrect output
- Delete (or "comment out") suspect code
- Using the alert function to trace code
- Help from Text Editor (e.g. jEdit)
- Color coding shows strings
- Matching parentheses are marked
- Check HTML code
- Help from browsers
- Google Chrome: Wrench Icon --> Tools --> Javascript Console
- Firefox: Start the Error Console under the Tools menu
- Internet Explorer: Tools --> Internet Options --> Advanced tab --> select Display a Notification about Every Script Error
What's wrong with this page?
Find the bugs in this tip calculator
page.
- Abstraction and Predefined Functions
Here's a simple page that uses a
predefined square-root function. Here's a reference to predefined
functions (look under JavaScript Math Objects and Javascript
Global Properties and Functions for the most common
functions).
Dave Reed has created a library of useful random functions. Here
is one example that uses the random
functions. Here's a link to these functions.
- Creating Your Own Functions
Functions that are called as part of an expression should have
a return value. Functions that are called by a user event (button
press) should not have a return value. A more comprehensive
reference to functions can be found online.
Function concepts and terms you should know:
- argument and parameter
- local variable
- return value
- using functions as abstractions
- Assignment 5
- Midterm exam is next Tuesday (October 11)