Dress to impress; reference error: shorts not defined


#1

Could someone help me by telling me what the problem with the code below is? I keep getting a ReferenceError saying that shorts are undefined.

var suitcase = {
    shirt: "Hawaiian"
};

if (suitcase.hasOwnProperty(shorts)=== true){
    console.log(suitcase.shorts);
    } else if (!suitcase.hasOwnProperty(shorts)){
    suitcase.shorts = "khaki";
    console.log(suitcase.shorts);
    };


#2

Hello @netjumper97942,

Try replacing your else if (condition) with an else clause...


#3

Getting the same error


#4

Can you please post your updated code... Thanks!


#5

I have figured out why you are unable to pass this exercise. It is because you haven't put "shorts" in quotes. It is a part of the .hasOwnProperty() method of classes...


#6

LOL, so that's what it was! Thanks.


#7

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