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

How do I stop the loop after 5 grade entries? It is currently an infinite loop.

ID: 3538520 • Letter: H

Question

How do I stop the loop after 5 grade entries? It is currently an infinite loop.  HERE IS MY CODE:



<html>
<head> <title> Oops, its loops </title> </head> <body> <script type="text/javascript"> // Question) take in some grades, calculate the average, // finally, display the average. var grade; var total; var count=0; var average; var loop=true; total=0; do { grade = 1*prompt("Enter the grade",""); total = total + grade; count++; // use a confirm here to make it loop }while(loop==true) // also written as while(loop) average = total/count; document.write("average is "+average); </script> </body> </html>

Explanation / Answer


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote