Skip to content

Instantly share code, notes, and snippets.

@qaisarmehmood
Created December 15, 2017 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qaisarmehmood/20d11096e51c1573279ee756d8c1748d to your computer and use it in GitHub Desktop.
Save qaisarmehmood/20d11096e51c1573279ee756d8c1748d to your computer and use it in GitHub Desktop.
Leveraging Web Data Class 5 Homework
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>QAISAR MEHMOOD</title>
</head>
<body>
<h1 style="text-align: center;"> Leveraging Web Data Class 5 Homework</h1>
<p>Answer the following questions about JavaScript. These questions may require you to do your own research to determine the best answer.</p>
<br>
<p>Developer Resources</p>
<ul>
<li><a href="https://www.google.com" target="_blank">Google</a></li>
<li><a href="https://www.stackoverflow.com" target="_blank">Stack Overflow</a></li>
<li><a href="https://www.w3schools.com/" target="_blank">W3 Schools</a></li>
<li><a href="http://devdocs.io/javascript/" target="_blank">Dev Docs</a></li>
</ul>
<br>
<h2>Basic</h2>
<h3>Append your name to the text between the title tags.</h3>
<br>
<h3>Describe the purpose of JavaScript, how might it relate to web mapping and visualization?</h3>
<p> Javascript is a client side scripting language and the purpose of javascript is to make our pages interactive and to create responsive websites.Javascript comes with web animation API's and advanced frameworks which are used altogether to create highly responsive interfaces which improves the user experience and provide dynamic functionality. Earlier than javascript have to wait for the server to react and show another page.
</p>
<br>
<h2>Variables</h2>
<h3>What is a variable? Provide two examples of using a variable.</h3>
<p>Variable is a data holder to store the values and return them when it is called.
Example 1
var x = 2 here x is the variable holding a value 2
Example 2
Myfunction(anyvalue){
var i = anyvalue
.....logic/statement} here variable i will hold any value passed to the function asa parameter.
Example 3
var qaisar = 4433 here the variable qaisar is holding value which is 4433.
</p>
<br>
<h3>Write out how to assign the variable x equal to 10.</h3>
<p>var x = 10</p>
<br>
<h2>Operators</h2>
<h3>Describe the differences between =, ==, and ===.</h3>
<p>
= will just check the euality of the value assigned x=y , x=z, then y=z
== will check only the object equality and not functional equality. 0 == false will be true.
=== will check both object equality and functional equality. 0 === false // will be false because they are of a different data type.
</p>
<br>
<h3>What would be the result of "Hello " + 10? Why?</h3>
<p> It will return Hello10 because "Hello" is a string and 10 is a character and when they are concatenated and run,the javascript engine read the values left to right so it will read the "Hello" first which is a string and it will take the 10 also as a string.
</p>
<br>
<h2>Loops</h2>
<h3>What is the purpose of a for loop? Describe in detail the advantages of using the for loop.</h3>
<p>The for loop is known as a control flow statement and main purpose of for loop is iterartion and allow code to execute repeatedly.
Advantages of for loop
if we want to print soemthing on the screen e.g 100 times then we have to type the code as many times but if we use a loop we dont have to type a code again and again we will just put the code in the loop and iterate it as many time as we want.
</p>
<br>
<h3>Describe the while loop in JavaScript.</h3>
<p> while statement is one of the conditional statements and it will creates a loop which will run for a specific time until the condition passed on to the loop is true known as while loop.
while(condition) { code }
</p>
<br>
<h2>If/Else Statements</h2>
<h3>What are the three <a href="https://www.w3schools.com/js/js_if_else.asp" target="_blank">conditional statements</a>? Describe how each are used.</h3>
<p>There are 3 conditional statements which are if, else and else if.
1. If is used to specify a condition which could be true of false e.g. if (3>0)
2. else is used to specify the code block to be executed if the provided if condition is false. else {code}
3. else if is used to provide an alternate condition to be checked after the first if condition as a second condition to be checked. else if(5>3){code}
</p>
<br>
<h3>What is the difference between using two if statements together compared to using an if statement then an else if statement or else statement?</h3>
<p> when we use an if statement inside an if statemnt its called nesting. This will happen if we nest two if conditions.
if (condition 1) {
if (condition 2){ i will be executed if both condition 1 and 2 will be true }
i will be executed if only condition 1 is true.
}
Condition 2 will only be checked if condition 1 is true otherwise if condition 1 is false the condition 2 wont even be get checked at all.
where as both conditions are checked in the case below
if(condition 1){ code}
else if (condition 2) {code}
else {code}
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment