Create a function toGradePoints() that takes an array of letter grades as input and returns a corresponding array of grade points

Y

Yuxin Jiang

Guest
function toGradePoints(letter) {
//var score = '';
var grade = [];

for (var i = 0; i < letter.length; i++)
{
//result = '';
if (letter = "A") {
grade = 4.0;
} else if (letter = "A-") {
grade = 3.7;
} else if (letter = "B+") {
grade = 3.3;
} else if (letter = "B") {
grade = 3.0;
} else if (letter = "B-") {
grade = 2.7 ;
} else if (letter = "C+") {
grade = 2.4;
} else if (score = "C") {
grade = 2.0;
} else if (score = "C-") {
grade = 1.7;
} else {
grade = 0;
}
// result.push(score);
}
return grade;

}

var y=[]
y=["B","B+","C-","D"];

var m=toGradePoints(y);

console.log(m)

Here is the link, q1.2

It only displays 4 all the time, I don't know which part went wrong.

Continue reading...
 
Top