HTML with JAVASCRIPT Please add a exit by entering 999, in the promp, so it look
ID: 3872033 • Letter: H
Question
HTML with JAVASCRIPT
Please add a exit by entering 999, in the promp, so it looks like this below.
MY code so far.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display letter grade</title>
<script>
var num;
do {
num = prompt(“Enter number grade from 0 through 100 [0 -100]", "0");
} while (isNaN(num) || num < 0 || num > 100);
var grade ;
if(num >= 88 && num <= 100)
grade = 'A';
else if(num >= 80)
grade = 'B';
else if(num >= 68)
grade = 'C';
else if(num >= 60)
grade = 'D';
else
grade = 'F';
alert("The letter grade is " + grade);
</script>
</head>
<body>
<section>
<h1>I hope you enjoyed the grade converter!</h1>
</section>
</body>
</html>
Explanation / Answer
Hi,
I have updated the code.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display letter grade</title>
</head>
<body>
<section>
<h1>I hope you enjoyed the grade converter!</h1>
</section>
<script>
var num = 0;
while(num != 999) {
do {
num = parseInt(prompt("Enter number grade from 0 through 100 [0 -100]", "0"));
} while ((num < 0 || num > 100) && num != 999);
if(num != 999) {
var grade ;
if(num >= 88 && num <= 100)
grade = 'A';
else if(num >= 80)
grade = 'B';
else if(num >= 68)
grade = 'C';
else if(num >= 60)
grade = 'D';
else
grade = 'F';
alert("The letter grade is " + grade);
}
}
</script>
</body>
</html>
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.