Skip to content

Instantly share code, notes, and snippets.

@adamwd392
Created December 11, 2017 23:39
Show Gist options
  • Save adamwd392/a26f5a1ad24bbf2d71cc96d0f10b2335 to your computer and use it in GitHub Desktop.
Save adamwd392/a26f5a1ad24bbf2d71cc96d0f10b2335 to your computer and use it in GitHub Desktop.
GES679-Assignment5-AdamDuvall
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
margin: 0;
}
</style>
<body>
Describe the purpose of JavaScript, how might it relate to web mapping and visualization?
<p>JavaScript is used to manipulate data and allow for user interaction with a webpage. In mapping and visualization, there are different
JS open source libraries such as D3 that can be used to visualize different geoprocessing efforts/spatial data.
</p>
Variables
What is a variable? Provide two examples of using a variable.
<p>A variable is a specific type of value that can change based on a variety of factors. Using a counter in a for loop is an example of
using a variable. Something that can either be true or false is stored as what is called a boolean variable.</p>
Write out how to assign the variable x equal to 10.
<p>var x = 10;</p>
Operators
Describe the differences between =, ==, and ===.
<p>'=' is used to assign or declare the value of a variable. '==' and '===' are both used when comparing the values of different
variables. '==' returns true when the variables are equal regardless of type, whereas '===' only returns true when both the value
and type of the compared variables match.</p>
What would be the result of "Hello " + 10? Why?
<p>The result would be "Hello 10". This is because in JS, the + operator is used both for numeric addition and string concatenation.
String concatenation is when something is appended to the end of a string. In this case the 10 is appended to the end of the string, "Hello".</p>
Loops
What is the purpose of a for loop? Describe in detail the advantages of using the for loop.
<p>For loops are used to repeat a sequence of steps a specified amount of times. The advantages of a foor loop is that
you dont have to repeat similar lines of code many times. You can run a loop that executes the sequence each time with control
over how the sequence runs based on what the increment value is currently at.</p>
Describe the while loop in JavaScript.
<p>A while loop is similar to a foor loop in that is used to run a sequence of a code repeatedly. The difference is that
while a for loop runs a pre-determined amount of times, a while loop continuously runs until a certain condition is met, or is true.</p>
If/Else Statements
What are the three conditional statements? Describe how each are used.
<p>The three conditional statements are the if statement, if..else statement, and switch statement. If statements are used
to execute a block of code provided that the if statement is true. Otherwise nothing happens. If...else statements are similar to
if statements except that if the if statement is not true, instead of nothing happening, the block of code following else is executed
instead. Switch statements are used when looking to execute many different blocks of codes depending on as many statements as
you need. </p>
What is the difference between using two if statements together compared to using an if statement then an else if statement or else statement?
<p>The difference between using 2 if statements together rather than an if statement followed by an else if or else is that if the
first if statement passes and the block of code is executed, with 2 if statements, the 2nd block of code could still execute while
with an if statement followed by an else if or else, only the first block would execute and then the code would stop running.</p>
<script>
function myNewFunction() {
for (i=0; i < 100; i++) {
if (i%3==0 && i%5==0) {
console.log("Hello World");
}else if (i%3==0){
console.log("Hello");
}else if (i%5==0){
console.log("World");
}else {
console.log(i);
}
}
}
myNewFunction();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment