30/30 Private Eye, help


#1

Been stuck on this for half an hour, could someone walk me through what the ■■■■ I'm doing wrong?

function StudentReport() {
var grade1 = 4;
var grade2 = 2;
var grade3 = 1;
this.getGPA = (grade1 + grade2 + grade3) / 3;

}

var myStudentReport = new StudentReport();

for(var x in myStudentReport) {
if(typeof myStudentReport[x] !== "function") {
console.log("Muahaha! " + myStudentReport[x]);
}
};

console.log("Your overall GPA is " + myStudentReport.getGPA);

I get "Muahaha! 2.3333333333333335
Your overall GPA is 2.3333333333333335" printed to the console, with the Try Again saying I should only print one thing to the console. How can I stop the muahaha ■■■■ from coming through?


#2

Have fiddled around with it, now

function StudentReport() {
var grade1 = 4;
var grade2 = 2;
var grade3 = 1;
this.getGPA = (grade1 + grade2 + grade3) / 3;

}

var myStudentReport = new StudentReport();

for(var x in myStudentReport) {
if(typeof myStudentReport[x] === "function") {
console.log("Muahaha! " + myStudentReport[x]);
}
};

console.log("Your overall GPA is " + myStudentReport.getGPA);

Now I just get "Your overall GPA is 2.3333333333333335", which despite being the objective Codecademy has set me, and GPA being a public fucking method,, i still get an error:

"Oops, try again. Make sure that getGPA is a public method!"

getting sick of this. what am i doing wrong???


#3

Nevermind, figured it out (painfully):

function StudentReport() {
var grade1 = 4;
var grade2 = 2;
var grade3 = 1;
this.getGPA = function() {
return(grade1 + grade2 + grade3) / 3;
};

};

var myStudentReport = new StudentReport();

for(var x in myStudentReport) {
if(typeof myStudentReport[x] !== "function") {
console.log("Muahaha! " + myStudentReport[x]);
}
};

console.log("Your overall GPA is " + myStudentReport.getGPA());