We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
classStudentextendsPerson{/* * Class Constructor * * @param firstName - A string denoting the Person's first name. * @param lastName - A string denoting the Person's last name. * @param id - An integer denoting the Person's ID number. * @param scores - An array of integers denoting the Person's test scores. */// Write your constructor hereconstructor(firstName,lastName,idNumber,testScores){super(firstName,lastName,idNumber)this.testScores=testScores}/* * Method Name: calculate * @return A character denoting the grade. */// Write your method herecalculate(){letavg=0letsum=0for(leti=0;i<this.testScores.length;i++){sum+=this.testScores[i]avg=sum/this.testScores.length}if(avg>=90&&avg<=100){return'O'}elseif(avg>=80&&avg<90){return'E'}elseif(avg>=70&&avg<80){return'A'}elseif(avg>=55&&avg<70){return'P'}elseif(avg>=40&&avg<55){return'D'}elseif(avg<40){return'T'}}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Day 12: Inheritance
You are viewing a single comment's thread. Return to all comments →
javascript