30/30 Private Eye, help

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 !== “function”) {
console.log("Muahaha! " + myStudentReport);
}
};

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?

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 === “function”) {
console.log("Muahaha! " + myStudentReport);
}
};

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 ■■■■■■■ 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???

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 !== “function”) {
console.log("Muahaha! " + myStudentReport);
}
};

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

1 Like