Dressed To Impress


I completed the task but the console returned 'undefined.' I'm not entirely sure I did this correctly. Isn't it supposed to return 'shorts'?

I looked at some other threads and tried their code. I just want to understand why the console ran through even though I didn't follow the instructions properly.

var james = {
    job: "programmer",
    married: false

var suitcase = {
    shirt: "Hawaiian"

if(suitcase.hasOwnProperty("shorts")) {
} else {
    var shorts = suitcase.shorts;


lets break it down, the if condition evaluates to false, agree? so else run. in which you create a variable called shorts, which you give a value of suitcase.shorts, but suitcase has no shorts property, so the variable shorts gets assigned a undefined value

does this make sense?


Yes, I understand. So, if I give shorts a different value instead of suitcase.shorts, say "orange" it would return that value?


then shorts will be assigned a value of oranges yes, but to pass the exercise, you need a object property, so you could do for example:

var shorts = suitcase.shirt;

now shorts will hold a value of Hawaiian


Would the value be 'Hawaiian' in that case?


yes, it would. Sorry, my fault. I copy pasted it, but codecademy has a safegaurd, if you copy paste and then don't type anything anymore, the pasted thing won't show.


Got ya. Thanks a lot!