Project 3 - WEB 124

  1. Read Chapter 3 Functions, Methods, & Objects
  2. Key the code exercises throughout Chapter 3.
  3. Watch applicable youtubes.
  4. Complete the following exercises by building a single semantic, validated, spell-checked web page with both the questions and the answers. Apply a linked, validated, flexible, and visually pleasing style sheet. Post your files to the student web server and put the corresponding URL in the Project 3 drop box.
  5. Note color coding: keyword, blue: HTML, pink: CSS, green: JavaScript, black: general instructions)

As always, spell check all content and identify your name and the current date in all files using comments. In html files you may use the html meta tag, e.g. <meta name="author" content="John Doe">.


Chapter Debrief


JavaScript variable names: Create and complete the following table

Which JavaScript variable names are valid and why?

variable name valid? yes or no If NOT valid, why NOT? If valid, from a best practices standpoint, is this a good variable name or not? If NOT, why NOT?
JCCC
$JCCC
_JCCC
%JCCC
1jccc
jccc
jccc-ks
jccc.ks
var
function
streetaddress
streetAddress
StreetAddress
street-Address

JavaScript Arrays!

In html file....

Render your page in the browser and fix any errors using the html and css validators! In the browser, open the Console. (right-click your browser|Inspect|click Console tab)

In external js file named project3.js, after a comment with your name and the current date....

Save your JavaScript, refresh your html page in the browser, and fix any errors noted in the Console! (aka. Save, refresh, fix, repeat.) You should see the values of your months array in the Console!

Expand your array list to see each element in the array by clicking the arrow to the left of it in the console.

In external js file...

Save, refresh, fix, repeat. Now the console.log statement logs the original array values but when you expand the array list in your console, you should see the value of the first element in the array change to January!

In external js file...

Save, refresh, fix, repeat. Note that the first item in the months array now logs out as "January".

In external js file...

Save, refresh, fix, repeat.

In external js file...

Save, refresh, fix, repeat.


Array Review Questions...

  1. What is the difference between using "quotation marks" versus 'apostrophes' in JavaScript? Insert your answer as text directly into a new id="p10" paragraph.
  2. What is the key difference between the innerHTML property and the textContent property? Insert your answer as text directly into a new id="p11" paragraph.
  3. For a reference to a month, why might it make more sense to reference an array value vs. a variable? Insert your answer as text directly into a new id="p12" paragraph.

Function terminology: Create and Complete the Following Table

term definition
function
statement
parameter
argument
return value
function declaration
function expression
anonymous function
immediately invoked function expression

Function Review questions ...

  1. How do you call a function named showTotal if it doesn't have any parameters?
    Insert your answer as text directly into a new paragraph identified as id="f1".
  2. How do you call a function named showTotal if it has two parameters named tax and total and you wish to pass the number 2 as an argument to the tax parameter and 10 as an argument to the total parameter?
    Insert your answer as text directly into a new paragraph identified as id="f2".
  3. How do you call a function named showTotal if it has two parameters named tax and total and you wish to pass the variable stateTax as an argument to the tax parameter and totalBeforeTax as an argument to the total parameter?
    Insert your answer as text directly into a new paragraph identified as id="f3".

Variable Scope questions...

  1. What JavaScript statement forces you to explicitly declare all variables, and where is it placed?
    Insert your answer as text directly into a new paragraph identified as id="s1".
  2. What are two ways to create a global (window-level) variable?
    Insert your answer as text directly into a new paragraph identified as id="s2".
  3. What JavaScript keyword is used to create a block-level variable?
    Insert your answer as text directly into a new paragraph identified as id="s3".

Object Terminology: Create and Complete the Following Table

term definition
object
property
method
key
literal notation
dot notation
constructor notation
this
undefined

User-Created Object questions...

  1. What is the benefit of using literal notation over constructor notation to create an object?
    Insert your answer as text directly into a new paragraph identified as id="j1".
  2. What is the benefit of using constructor notation over literal notation to create an object?
    Insert your answer as text directly into a new paragraph identified as id="j2".
  3. If a function is created in the global scope, what does this refer to?
    Insert your answer as text directly into a new paragraph identified as id="j3".
  4. If a function is created within an object, the function becomes a method of that object. In that case, what does this refer to?
    Insert your answer as text directly into a new paragraph identified as id="j4".

Storing Data....

In your js file, declare the following items to store data. After each declaration, add a console.log statement to review the data in the browser console.

  1. A variable to store your full name
  2. A variable to store your desired annual salary
  3. A variable to store your veteran status (either you are a veteran or you are not a veteran)
  4. An array to store the names of three of your friends.
  5. An array to store the value of the desired annual salary for your three friends
  6. A literal object to store the first name, last name, and desired annual salary of yet another friend

Built-in Objects: Create and Complete the Following Table

Browser Document Global String Global Number Global Math Global Date
Example of a common method for that object
Explanation of example

Data Types: Create and Complete the Following Table

String Number Boolean Undefined Null
Provide an example of how to declare a variable with each of these data types.