D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
yopoku
Full window
Github gist
Assignment 5 Yaw OpokuAdarkwa
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Yaw Opoku Adarkwa</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="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 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 </p> <br> <h2>Variables</h2> <h3>What is a variable? Provide two examples of using a variable.</h3> <p>A variable in JavaScript is a container that stores data values.</p> <p>A value is assigned to a specific container and can then be referenced by naming the particular container</p> <p>For example, in order to declare variables for data values 'song' and 'year', var song; var year;</p> <br> <h3>Write out how to assign the variable x equal to 10.</h3> <p><script> var x =10; </script></p> <br> <h2>Operators</h2> <h3>Describe the differences between =, ==, and ===.</h3> <p>= assigns a value to a variable</p> <p>== means equal. Checks if two values are equal or not</p> <p>=== means equal value and equal type. Checks if two values are equal and have the same data type</p> <br> <h3>What would be the result of "Hello " + 10? Why?</h3> <p>Hello10</p> <p>Because adding a number a string returns a string as a result</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>A for loop repeats an action for some number of times until a condition evaluates to false</p> <p>It is versatile and easy to use and able to handle all manner of looping tasks</p> <br> <h3>Describe the while loop in JavaScript.</h3> <p>The while loop evaluates the condition and if true,the block of statements following the while statement is executed </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>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.</p> <p>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</p> <p>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</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>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.</p> <br> <script type="text/javascript"> // // code goes below this line var i; function myNewFunction() { for(i = 0; i<100; i++){ document.write("loop iteration number "+i) if (i % 3 == 0 && i % 5 == 0){ console.log('HelloWorld')} else if (i % 3 == 0){ console.log('Hello')} else if (i % 5 == 0){ console.log('World')} else {console.log(i) } document.write('<br>') } }; myNewFunction(); </script> </body> </html>