Skip to content

Instantly share code, notes, and snippets.

@jkarnowski
Created March 17, 2016 19:05
Show Gist options
  • Save jkarnowski/6f82e913566b4dcf8f51 to your computer and use it in GitHub Desktop.
Save jkarnowski/6f82e913566b4dcf8f51 to your computer and use it in GitHub Desktop.
// a start to refactoring code from phase-2 assessment
function Student(firstName, scores) {
this.firstName = firstName;
this.scores = scores;
}
Student.prototype.averageScore = function(scores) {
var sum = 0
for(var i = 0; i < this.scores.length; i++) {
sum += this.scores[i];
}
var average = sum / this.scores.length;
return Math.floor(average);
};
Student.prototype.letterGrade = function() {
var scoresFromAverageScoreFunction = this.averageScore();
console.log(scoresFromAverageScoreFunction);
if (scoresFromAverageScoreFunction >= 90) {
return "A"
// return this.letterGrade = "A";
}
else if(scoresFromAverageScoreFunction >= 80){
return "B"
}
//not getting the letter grade function to work properly
};
// var Student = function(name, scores) {
// this.name = name;
// this.title = title;
// };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment