Skip to content

Instantly share code, notes, and snippets.

@SRNT
Last active January 29, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SRNT/58954661311c9baec71753496bcb8224 to your computer and use it in GitHub Desktop.
Save SRNT/58954661311c9baec71753496bcb8224 to your computer and use it in GitHub Desktop.
For checking a student grade with percentage
const gradScore = (sScore, totalScore = 100) => {
const score = Math.floor(sScore / 10);
var grade = {
10: 'A',
9: 'A',
8: 'B',
7: 'C',
6: 'D',
5: 'F',
4: 'F',
3: 'F',
2: 'F',
1: 'F',
0: 'F'
} [score];
return `You got ${grade} (${sScore}%)`;
};
let studantScore = gradScore(90);
console.log(studantScore);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment