Leveraging Web Data Class 5 Homework

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 created to enable work or chages to be done within the user's web browser , even when offline.It's ability to be used in creating high responsive interfaces and dynamic funtionality makes it convenient to be used for web maps designs and visualization


Variables

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

A variable in JavaScript is a container that stores data values.

A value is assigned to a specific container and can then be referenced by naming the particular container

For example, in order to declare variables for data values 'song' and 'year', var song; var year;


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


Operators

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

= assigns a value to a variable

== means equal. Checks if two values are equal or not

=== means equal value and equal type. Checks if two values are equal and have the same data type


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

Hello10

Because adding a number a string returns a string as a result


Loops

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

A for loop repeats an action for some number of times until a condition evaluates to false

It is versatile and easy to use and able to handle all manner of looping tasks


Describe the while loop in JavaScript.

The while loop evaluates the condition and if true,the block of statements following the while statement is executed


If/Else Statements

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

1. The if statement- Its the most common type and used to specify a block of code to be executed if a condition is true.

2. The else statement- This is an extension of the if statement wnd adds another block of code to run when the condition of the if statement is false

3. The else if statement- It is used to specify a new condition if the first condition is false.It extends an if statement byadding another condition with its own block


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

Multiple if statements may be used instead of else or else if statements. By using multiple if conditions,JavaScript has to go through each condition, whereas with else and else if conditions, JavaScript has to check conditions until it finds a condition that returns value to be true.