CHAPTER 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8

Chapter 1 - Answers

  1. (True or False) JavaScript is an interpreted language.
  2. JAVA is a compiled programming language, and is platform independent.
  3. (True or False) JAVA and JavaScript were created by the same company.
  4. Microsoft Internet Explorer supports the following scripting languages.
  1. JavaScript
  2. JAVA
  3. BASIC
  4. VBScript
  5. C++
  6. Perl
  1. (True or False) JavaScript is supported by a large number of browsers.

 

Chapter 2 - Answers

  1. Which of the following are valid variable or function names:
  1. y
  2. 100percent
  3. a big number
  4. break
  5. subtractTwoNumbers
  6. First_Name
  1. Place the brackets in the correct locations indicated by the underscore.
  2. if ( z[0] == 0 ) {

    x = 2;

    }

  3. Complete this sentence: All statements should end in a semicolon.
  4. True or False. JavaScript is a case insensitive language.
  5. True or False. It is a good idea to add comments to your program code.
  6. Match the brackets in Column A with the use in Column B.

Column A

Answer

Column B

a. { }

b

used for array index values

b. [ ]

c

used to contain a functions, arguments

c. ( )

a

used to contain multiple JavaScript statements

 

 

Chapter 3 - Answers

  1. True or False. Variables in JavaScript are strongly typed.
  2. True or False. You can declare a number of variables all at once.
  3. The var keyword is used to declare variables.
  4. Match the operator with its function.
  5. Column A

    Answer

    Column B

    a. =

    a

    assignment

    b. ==

    c

    addition

    c. +

    b

    equality

     

  6. Create an if structure that will make sure the value of the p variable is greater than or equal to 99, and if so set the total equal to the value of p.
  7. if ( p >= 99 ) {

    total = p;

    }

     

  8. Create a function that will multiply two numbers together and return the result.

function multiplyTwoNum( m, n ) {

var total;

total = m * n;

return total;

}

or

function multiplyTwoNum( m, n) { return m * n; }

 

Chapter 4 - Answers

 

  1. An object is a collection of methods and parameters.
  2. The four objects that are built into the JavaScript language are:
    1. String
    2. Date
    3. Array
    4. Math

  3. (True or False) The DOM is a collection of objects added to the JavaScript language by the browser

  4. (True or False) Events are key to beginning the execution of your scripts.

  5. Which event would you use to start a script after a page has been fully loaded by the browser?
      1. onClick()
      2. onSubmit()
      3. onLoad()
      4. onMouseOver()
      5. onload()

  6. (True or False) Events are tied to specific HTML elements.

 

 

Chapter 5 - Answers

 

  1. What are the predefined, popup style, dialogue boxes we can use with JavaScript?
    1. window.popup()
    2. window.confirm()
    3. window.prompt()

     

  2. Which type of dialogue box would you use if you want the user to enter some information?
  3. window.prompt()

  4. What is concatenation?

Concatenation is the combination (or addition) of two or more strings into one string.

 

Chapter 6 - Answers

 

  1. What event was used to place the cursor in the first field of our FORM?
  2. onFocus event is used to put the cursor in the first field of the form. It is used in our example in conjunction with the onLoad event.

     

  3. What did we test to see if the user had entered any information into any of the fields?
  4. We tested to see if the length of the string typed in by the user was greater than one character.

     

  5. What does the "return" statement do?
  6. The return sends a value back to the statement that invoked it. When a function is done it can send only one value back, this is done through the return statement.

     

  7. How do we get the next error message to appear on the next line down?
  8. We use the \n (newline literal) in the string.

     

  9. What function is used to verify that certain entries are numbers?

The isNaN() (is not a number) function is used to test a string to see if it only contains numbers.

 

Chapter 7 - Answers

 

  1. What two events are used to create the mouse roll-over effect?
  2. onMouseOver

    onMouseOut

  3. What properties of the image object can you read and write?
  4. src (source)

    lowsrc (low res source)

  5. Which property is a Boolean value you can test for?
  6. complete

  7. Why do we pre-load our images?
  8. So that we can quickly switch between the two image objects when the user is moving their mouse pointer over and off the image.

  9. Why is it important to test to see if the images have completely downloaded?
  10. So that we don't try to show a user an image that is partially loaded into their browser.

  11. What would you need to add to our script to get it to work with more than two links?

The only thing you need to add to the script is some new image objects for the additional links. The logic section does not need to updated.

 

Chapter 8 - Answers

  1. What are the two methods used with popup windows?
  2. window.open()

    window.close()

  3. What are some good uses of popup windows?
  4. Display a picture, or more details about a product that a potential customer is interested in.

  5. (True or False) You can not control the size of a popup window?

  6. (True or False) It is not common to see popup windows displayed with all of the features turned off.