Leveraging Web Data Class 5 Homework
Pamela Griner

Answer the following questions about JavaScript. These questions may require you to do your own research to determine the best answer.


Developer Resources


Basic

Append your name to the text between the title tags.


Describe the purpose of JavaScript, how might it relate to web mapping and visualization?

JavaScript is used to manipulate web pages, perform actions, animate and style web pages, and allow the user to interact with the web page


Variables

What is a variable? Provide two examples of using a variable.

JavaScript variables are containers for storing data values. Examples are string and numbers.


Write out how to assign the variable x equal to 10.

To write out how to assign the variable x equal to 10, you would need to add "var x = 10"


Operators

Describe the differences between =, ==, and ===.

In JavaScript, the equal sign (=) is an "assignment" operator, not an "equal to" operator. The "equal to" operator is written like == in JavaScript. = allows you to state the variable, == allows for a comparison on the variables, i.e., 5 == "5" is a "true" statement, if it is 5 === "5" the statement would be "false" beacuse === is identified as text and not a number.


What would be the result of "Hello " + 10? Why?

The result would be found in iteration 5 because it divides into 10 evenly.


Loops

What is the purpose of a for loop? Describe in detail the advantages of using the for loop.

Loops offer a quick and easy way to do something repeatedly.


Describe the while loop in JavaScript.

The while loop loops through a block of code as long as a specified condition is true.


If/Else Statements

What are the three conditional statements? Describe how each are used.

"If" is used to specify a block of code to be executed, if a specified condition is true; "else" is used to specify a block of code to be executed, if the same condition is false, and "else if" is used to specify a new condition to test, if the first condition is false.


What is the difference between using two if statements together compared to using an if statement then an else if statement or else statement?

Using two "If" statements together would require the script to check both statements to verify if the condition is true and using an "if" statment with an "else" statement would only verify the "if" statemnt if it is true would not check the "else" statement.