Lesson 8.Dressed to impress


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

var suitcase = {
    shirt: "Hawaiian"

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


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


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.