To Lecture Notes

IT 130 -- 2/10/09

 

Review Questions

  1. Name four types of literals in JavaScript.
    Ans: Integer (e.g., 3465), floating point (e.g., 3.14159), string (e.g., Hello) boolean (true or false).
     
  2. What does variable initialization mean?
    Ans: It means declaring and assigning a value to a variable in one statement like this:
    var x = 5;.
     
  3. Which of these are legal JavaScript variable names? A variable name must start with a letter and consist of letters or digits.
    Ans: abc (legal) b768 (legal) 4slots (not legal) hook&ladder (not legal) numberOfCustomers (legal) number-of-customers (not legal) anExtremelyLongVariableNameIfYouAskMe (legal, but too long to be easy to read
     
  4. What does camel casing mean?
     
  5. Ans: Each new word within a variable name is spelled in upper case.
     
  6. Give five JavaScript operators.
    Ans: + (addition or concatenation)  -  *  /  =
     
  7. What is wrong with this statement? Ans: A constant cannot occur on the left side of an assignment statement. The left side of an assignment statement is the target variable that is being changed.
     
  8. What does concatenation mean?
     
    Ans: To put two character strings together to make one longer string.
     
  9. Design a form with an input textbox, an output textbox and a submit button. In the onClick attribute for the button, write code that will input the amount in dollars and output the tax which is 8% of the amount. If the variable tax contains the amount of the tax, then use tax.toFixed(2) to round the tax to two decimal points before you show the answer in the output textbox.

 

The Concatenation Operator

 

Practice Problems

  1. What is shown in the alert box?

     
  2. What is the output of these JavaScript statements?

 

Abstraction

 

Built In Functions

 

User Defined Functions

 

Absolute Positioning Using Div Tags

 

Generating Random Integers

 

The Dice Examples

 

Project 5