30/30


#1

Has anyone any idea what should be changed in last exercise?
I have tried to eplaced this.getGPA = function() { by var getGPA = function() {
However, it doesn't work.


#2

Edit your post and give the code you have / are using....
and
please add the Instructions


#3

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());


#4

The only thing that you should need to change (it worked for me) in that exercise would be:

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

The rest of the code works fine and you shouldn't edit that


#5

This will work :grinning:

 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());