D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
AnaMal08
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> Anna Malek</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 a powerful and popular language for programming on the web. D3.js is a JavaScript library that offers powerful data visualization features for producing dynamic, interactive data visualizations in web browsers.</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. <br> A string variable is a series of characters like "John Doe". <br> variable as a number, for example: var x = 34;</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> A single equal operator is used to assign a value to a variable <br> When a comparison is made using a double-equals operator, it will check the values of a variable and convert them to a common type and returns true if both are equals. So comparing number with a string having the same value will return true. <br> for example: console.log(23 == "23"); // true <br> In contrast to double equals operator, another operator with three equals not made the implicit conversion so it not only compare values but also the type of variable that's why it is also called strict comparison. <br> for example: console.log(23 === "23"); // returns false </p> <br> <h3>What would be the result of "Hello " + 10? Why?</h3> <p>The result for 10 is "Hello" because 10 is divided by 5 and the remainder of operation is equal to zero. </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>For loop is used to run the same code over and over again, each time with a different value.</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>The if statement specifies a block of code to be executed if a condition is true <br> The else if statement specifies a new condition if the first condition is false <br> The else statement specifies a block of code to be executed if the 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>In our example the loop number (15) has to be divided by 3 & 5 to meet the first condition(execute "Hello World"). If we use if (i % 3 == 0), else if (i % 5 == 0), the first condition would be executed for 15 ("World") and the program would not check the second condition. </p> <br> <script type="text/javascript"> // // code goes below this line function myNewFunction(stop) { for (var i = 1; i < stop; 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(101); </script> </body> </html>