D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
qaisarmehmood
Full window
Github gist
ASSIGNMENT 5
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>Assignment 5</title> </head> <body> <h1>Questions</h1> <p> a. Name the new function myNewFunction() ? function myNewFunction(){ }; </p> <p> b. Write a for loop from 1 to 100, loop must iterate 100 times, not 99 or 101 times for (i = 1; i <= 100; i++) { console.log); } </p> <p> c. Within the for loop, use a series of if, else if, and else statements to evaluate if the remainder of the iteration divided by a particular number is zero for (i = 1; i <= 100; i++) { if (i % 2 == 0){ console.log("even"); } else if (i % 2 == 1){ console.log(“odd”); } else { console.log(i); } } </p> <p> d. Let the value of the iteration be a variable (var) named i: i. If i % 3 == 0 && i % 5 == 0, use the function console.log(“Hello World”) ii. Else if i % 3 == 0, console.log(“Hello”) iii. Else if i % 5 == 0, console.log(“World”) iv. Else console.log(i) var i; for (i = 1; 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); } } } </p> <p> e. Call myNewFunction()? myNewFunction(); ( to call our function we just have to use this command or we can add a button <button onclick="myNewFunction()">Run Script</button> ) </p> <p> BONUS QUESTION </p> <br> <script type="text/javascript"> function myNewFunction(x){ var i=x; for(vari=x; i<=100; i++){ console.log(i); } myNewFunction(x); </script> </body> </html> </body> </html>