Private Eye 30/30

Can someone please explain what the !== “function” bit means in the code below?

for(var x in myStudentReport) {
if(typeof myStudentReport !== “function”) {
console.log("Muahaha! " + myStudentReport);
}
Does it mean that it is checking to see if it is a function? or if it has a this. keyword? and if so it will make it public?

thanks in anticipation

@missmuffett Yes, I believe so… Well to be more accurate, checking to make sure it is not a function. (Unsure what “it” in “make it public” is referring to however.) @factoradic addressed the same question for me in detail here.

@missmuffett
Have a read in
== the Book ==


and the !== is called Non-identity / strict inequality (!==) operator

1 Like

THank you very much - I appreciate your help with this! I understand now.

1 Like

Thank you very much for your help - this was most helpful.

1 Like

My working exercise:

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

@datasolver35832, that is exactly how I did it as well.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.