Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

do-while loop question

sorry for not being clear, To start, this application should display a prompt dialog box like the one below that gets a number grade from 0 through 100. Then, it should display an alert dialog box that displays the letter grade for that number. for deriving the letter grade it like A 90-100 B 80-89 C 70-79 D 60-69 F < 60 and by using if-statement with the loop should get to display the number and letter grade, also doing the validation to make sure the number is valid from 0 through 100. and 999 for exiting the loop. hope i am clear

Hi Fadi,

You should post additional info in your original question here: https://teamtreehouse.com/community/can-you-please-show-me-how-to-get-the-number-of-grade-and-the-letter-grade-using-dowhile-loop-like-a-10090 rather than post the question again.

Also, you should be making some kind of attempt at the problem.

1 Answer

OK - that's a really bizarre way to generate a letter grade... Are you sure you don't mean something like this:

var valid=false;
var grade;

//prompt until user gives a valid response
do {
  //prompt user for number grade... grade=prompt("Enter numeric grade")
  //validate if number grade is number and between 0 and 100
} while (!valid)

if (grade >=90)  {
  alert("A");
} else if (grade >=80) {
 alert("B");
} //continue else...if