Question: I neeed help with my HTML code, I wrote a code but I can't seem to find where I did it wrong. I emailed it

I neeed help with my HTML code,

I wrote a code but I can't seem to find where I did it wrong. I emailed it in and the professor said that it wasn't what the assignment was asking

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

function load() {

var data = [];

document.getElementById('btnSubmit').addEventListener('click', function () {

// var line = prompt("Enter course name, grade, and credit hours (e.g. CS320 B+ 4) ");

var name = document.getElementById("name").value

var score = document.getElementById("grade").value

var credit = document.getElementById("credit").value

var values = [name, score, credit];

data.push(values);

display(data);

reset();

});

}

function reset() {

document.getElementById("name").value = "";

document.getElementById("grade").value = "";

document.getElementById("credit").value = "";

}

function display(data) {

var points = {

"A": 4,

"B+": 3.5,

"B": 3,

"C+": 2.5,

"C": 2,

"D": 1,

"F": 0,

"AF": 0,

"WF": 0

};

var hours = 0;

var table = document.getElementById('result');

table.innerHTML = "

CourseGradeHours

";

var sum = 0;

for (var i in data) {

var item = data[i];

table.innerHTML += "

" +

item[0] + "

" +

item[1] + "

" + item[2] + "";

sum += points[item[1]] * parseInt(item[2]);

hours += parseInt(item[2]);

}

var gpa = sum / hours;

var text = "
Total grade points = " + sum;

text += "
Number of hours = " + hours + "
";

text += "GPA = " + gpa; //printing the output

document.getElementById('text').innerHTML = text;

}

load();

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

my output looks like this

I neeed help with my HTML code, I wrote a code but

However it's wrong,

this is what it's asking for

I can't seem to find where I did it wrong. I emailed

this was my orignial code which i got full credit for,

function load() {

var data = [];

while (true) {

var line = prompt("Enter course name, grade, and credit hours (e.g. CS320 B+ 4) ");

if (line == null || line == "") {

break;

}

var values = line.split(/\s/);

data.push(values);

}

return data;

}

function display(data) {

var points = {

"A": 4,

"B+": 3.5,

"B": 3,

"C+": 2.5,

"C": 2,

"D": 1,

"F": 0,

"AF": 0,

"WF": 0

};

var hours = 0;

var table = document.getElementById('result');

table.innerHTML = "

CourseGradeHours

";

var sum = 0;

for (var i in data) {

var item = data[i];

table.innerHTML += "

" +

item[0] + "

" +

item[1] + "

" + item[2] + "";

sum += points[item[1]] * parseInt(item[2]);

hours += parseInt(item[2]);

}

var gpa = sum / hours;

var text = "
Total grade points = " + sum;

text += "
Number of hours = " + hours + "
";

text += "GPA = " + gpa; //printing the output

document.getElementById('text').innerHTML = text;

}

data = load();

display(data);

Some help would be great, i can't seem to figure thsi out

Enter course name, grade, and credit hours (e.g. CS320 B+4) Course Name Grade credit Course Grade Hours CS32 KinlBA 3 1 Total grade points NaN Number of hours 3 GPA NaN Output

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!