Created
March 17, 2016 19:05
-
-
Save jkarnowski/6f82e913566b4dcf8f51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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