a. Name the new function myNewFunction() ? function myNewFunction(){ };
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); }
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); } }
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); } } }
e. Call myNewFunction()? myNewFunction(); ( to call our function we just have to use this command or we can add a button )
BONUS QUESTION