UNPKG

score-to-ects-module

Version:

Converts 100-point scores to ECTS grades

19 lines (16 loc) 418 B
class ECTS { constructor(score) { this.score = score; } ectsFromScore() { const s = this.score; if (s >= 90 && s <= 100) return "A"; if (s >= 82 && s <= 89) return "B"; if (s >= 74 && s <= 81) return "C"; if (s >= 65 && s <= 73) return "D"; if (s >= 60 && s <= 64) return "E"; if (s >= 0 && s < 60) return "F"; throw new Error("Invalid score"); } } module.exports = ECTS;