function calcGPA(string) {
string = string.split(' ');
let total = 0
string.forEach(x => {
if (x >= 90) return total += 4
if (x >= 80) return total += 3
if (x >= 70) return total += 2
if (x >= 60) return total += 1
})
return total / string.length
}
const chai = require("chai");
const assert = chai.assert;
// Uncomment the following line to disable truncating failure messages for deep equals, do:
// chai.config.truncateThreshold = 0;
describe("Solution", function() {
it("Test", function() {
assert.strictEqual(calcGPA("100 95 92 99"), 4.0);
assert.strictEqual(calcGPA("80 44 31 91"), 1.75);
assert.strictEqual(calcGPA("72 9 69 72"), 1.25);
assert.strictEqual(calcGPA("41 32 71 30"), 0.5);
});
});