// Records the credits for each known course. const CREDITS: Map<string, number> = new Map([ ["CSE 341", 4], ["CSE 344", 4], ["CSE 421", 3], ["CSE 431", 3], ["CSE 444", 4], ]); // Returns the total credits for the given list of classes. (The list should // have no duplicates.) export function TotalCredits(classes: string[]) { let total : number = 0; for (let i = 0; i < classes.length; i++) { if (CREDITS.has(classes[i])) { total += CREDITS.get(classes[i])!; } else { throw new Error("no such class: " + classes[i]); } } return total; }