Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone answer these html questions for me please. In a comment in the head

ID: 3695816 • Letter: C

Question

Can someone answer these html questions for me please. In a comment in the head answer the following questions: How many times does the following loop execute and why? What is written to the document by the following loop? Explain how the following code works. In a script element in the body give the Java Script code for the following: A for loop that loops 7 times and prints out: 0 1 2 3 4 5 6. A while loop that loops 7 times and prints out: 2 4 6 s 10 12 14. A do while loop that loops 6 times and prints out: 1 2 3 4 5 6 A for loop that loops 7 times and prints out: 1 4 9 16 25 36 49.

Explanation / Answer

2)

* how many times does the following loop execute and why?

    for(i=0;i<10;i++){

          //loop body

       }

Ans-

for loop execute 10 times

because in that i=0.this value less than 10 so loop will be begin than i++ so i value=2 this also less than 10 so agin loop will be begin .the loop will stop when i reach value 10 because 10<10 is false .

var k=12;

while(k>7){

     document.write(k+"th item.");

k=k-1;

}

Ans-

Output will be generate

12th item

11th item

10th item

9th item

8th item

Because k=12 when loop start k>7(12>7) so loop will be begin output will be printed

K=k-1 so k=11 this also less than 12 so again output will be printed

The loop will be ended then k=7 because7>7 is false.

do

{

    responce=prompt("enter password", " ");

}

while(responce!="gamecooks")

Ans-

In javascript prompt is user input .

Input will be assign to responce variable

This loop will be continue until responce!="gamecooks"

If responce="gamecooks" then loop will stop

3)

1)

<script type=”text/javascript”>

Var i;

for(i=0;i<7;i++){

document.write(i);

}

</script>

2)

script type=”text/javascript”>

Var i;

for(i=2;i<=14;i+=2){

document.write(i);

}

</script>

3)

script type=”text/javascript”>

Var i=1;

do{

document.write(i);

i++

}while(i<7)

</script>

4)

script type=”text/javascript”>

Var i;

for(i=1;i<=8;i++){

document.write(Math.pow(i,2));

}

</script>