SHARE
TWEET

Untitled

a guest Jul 15th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // students score, total possible score
  2. // 15/20 -> You got a C (75%)!
  3. // A 90-100, B 80-89, C 70-79, D 60-69, F 0-59
  4.  
  5.  
  6.  
  7. let scoreCalc = function(studentScore, totalScore) {
  8.     return studentScore / totalScore
  9.     }
  10.    
  11.     let gradePercent = scoreCalc(17, 20)
  12.    
  13.     let gradeCalc = function(gradePercent) {
  14.     let gradeLetter
  15.     if (gradePercent >= 90) {
  16.     gradeLetter = 'A'
  17.     } else if (gradePercent <= 89 && gradePercent > 80) {
  18.     gradeLetter = 'B'
  19.     } else if (gradePercent <= 79 && gradePercent > 70) {
  20.     gradeLetter = 'C'
  21.     } else if (gradePercent <= 69 && gradePercent > 60) {
  22.     gradeLetter = 'D'
  23.     } else if (gradePercent <= 59) {
  24.     gradeLetter = 'F'
  25.     }
  26.     return gradeLetter
  27.     }
  28.    
  29.     let gradeLetter = gradeCalc(gradePercent * 100)
  30.    
  31.     console.log(`You got a ${gradeLetter} (${gradePercent * 100}%)!`)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top