Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //get score from user
- var score = prompt("Enter score: ");
- //display correcponding letter grade
- console.log("Your grade is: " + gradeCalc(score));
- //converts from number score to letter grade
- function gradeCalc(sco){
- var gra;
- //catch invalid scores
- if (sco<0 || sco>100){
- console.log("ERROR: ");
- return 'invalid';
- }else if (sco>90){gra='A';}
- else if (sco>80){gra='B';}
- else if (sco>70){gra='C';}
- else if (sco>60){gra='D';}
- else{gra='F';}
- return gra;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement