The project I created does not want to accept a half credit and I am not sure why not. When I put in 0.5 it only accepts the 0 and when I put in .5 it doesn’t accept any of it.
I was expecting the half credit to work but it doesn’t.
Here’s my code –
function addCourse() {
const courseName = courseNameInput.value;
const grade = gradeSelect.value;
const credits = parseInt(creditsInput.value);
const listItem = document.createElement('li');
listItem.textContent =
`${courseName} - Grade: ${grade} - Credits: ${credits}`;
courseList.appendChild(listItem);
updateGPA();
courseNameInput.value = '';
gradeSelect.selectedIndex = 0;
creditsInput.value = '';
}
function updateGPA() {
const courses = courseList.children;
let totalCredits = 0;
let totalPoints = 0;
for (let course of courses) {
const credits = parseInt(course.textContent
.split('Credits: ')[1]);
totalCredits += credits;
const grade = course.textContent
.split(' - ')[1]
.split(' ')[1];
totalPoints += getPointsForGrade(grade) * credits;
}
New contributor
user25247243 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.