Lesson 8.Dressed to impress


#1



Hello.Code works but shouldn't it print 'false' instead of 'blue?'


var suitcase = {
    shirt: "Hawaiian"
};

if (suitcase.hasOwnProperty('shorts')) {
    console.log(suitcase.shorts);
} else {
    suitcase.shorts = 'blue';
    console.log(suitcase.shorts);
};


#2

No, it should print the value of the shorts property, which is in your code blue


#3

As I understood, in 'else' branch we add the new property 'shorts' to our object 'suitcase', and set it value to string blue (in your case). Then we just logged it to console.