Reference no: EM133369960
Part 1 : Web Page with a Script Tag
As you did in the previous coding assignments, web page called <first_name>_<last_name>_hw4.html
For instance, I would create a file called:
Antonino_Cacioppo_hw4.html
and then create a simple HTML document with a single header1:
<H1>PART 1: Simple FOR Loop</H1>
<output of your loop>
<H1>PART 2: Simple FOR Loop with IF Condition</H1>
<output of your loop>
<H1>PART 3: Simple While Loop with IF Condition</H1>
<output of your loop>
<H1>PART 4: Simple While Loop with IF Condition using a Function</H1>
<output of your loop>
----- FORMAT ABOVE ----
Part 2 : Replace the Javascript Code in Web Page
PART 1: Simple FOR Loop (3 point)
loop from 1 to 25 and write the output with the loop count. Use the i variable for each loop.
The following is the code you want to put in your loop:
document.write("THIS IS THE FOLLOWING LOOP NUMBER: " + i + "<br");
where i is the variable you are using in your for loop.
PART 2: Simple FOR Loop with IF Condition
loop from 1 to 25 and write the output with the loop count using age is the loop counter.
Add an IF block to check if the age is less than 18, if so, print the following:
document.write("Your age is " + age + " and you are not able to vote<br");
If the age is equal to or greater than 18, then print:
document.write("Your age is " + age + " and you are able to vote, so vote !!!<br");
PART 3: Simple While Loop with IF Condition
Do the same thing as Part 3 except use a while loop instead. Feel free to use the age variable or new
Do the same as part 3 but instead create a function called checkAge which has the IF statement with the age check and the document.write call.
Pass in the age of your loop into the function.