D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
PGriner
Full window
Github gist
Leveraging Web Data Assignment 5
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Leveraging Web Data Class 5 Homework</title> </head> <body> <h1 style="text-align: center;"> Leveraging Web Data Class 5 Homework <br> Pamela Griner</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="https://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 used to manipulate web pages, perform actions, animate and style web pages, and allow the user to interact with the web page </p> <br> <h2>Variables</h2> <h3>What is a variable? Provide two examples of using a variable.</h3> <p>JavaScript variables are containers for storing data values. Examples are string and numbers.</p> <br> <h3>Write out how to assign the variable x equal to 10.</h3> <p>To write out how to assign the variable x equal to 10, you would need to add "var x = 10"</p> <br> <h2>Operators</h2> <h3>Describe the differences between =, ==, and ===.</h3> <p>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.</p> <br> <h3>What would be the result of "Hello " + 10? Why?</h3> <p>The result would be found in iteration 5 because it divides into 10 evenly.</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>Loops offer a quick and easy way to do something repeatedly.</p> <br> <h3>Describe the while loop in JavaScript.</h3> <p>The while loop loops through a block of code as long as a specified condition is true.</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>"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.</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>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.</p> <br> <script type="text/javascript"> // // code goes below this line function myNewFunction() { // // the first section of the for loop declares a variable (var) named i that is equal to 1 // the second section of the for loop indicates that this loop should consider as long as i is less than 6 // the third section of the for loop indicates that every loop, i should increase by 1 for (var i = 1; i < 101; i++) { // // the first if statement evaluates i // if i is divided by 3 and the remainder of operation is equal to zero then perform an action // in this instance, the action is to use the console.log() function to write "Geospatial" if (i % 3 == 0 && i % 5 == 0) { console.log("Hello World") } // // else if must be used to continue evaluating i as part of the same set of evaluations // using if, without else, will result in a new set of evaluations // else if (i % 3 == 0) { console.log("Hello") } else if (i % 5 == 0) { console.log("World") } // the final section of the if/else statement says that else i does not fit any of the previous statements else { console.log(i) } } }; myNewFunction(); </script> </body> </html>