Dress to impress 8 I don't know


#1

https://www.codecademy.com/en/courses/objects-ii/1/3?curriculum_id=506324b3a7dffd00020bf661#

Dont understand why I passed. I was expecting the result to be false, and to print out "You don't bring shorts". Thanks


Replace this line with your code. 

var suitcase = {
    shirt: "Hawaiian"
};

if(suitcase.shorts=true){
    console.log(suitcase.shorts);   
}else{
    suitcase.shorts=("You don't bring shorts");   
    console.log(suitcase.shorts);
}

suitcase.hasOwnProperty("shorts");


#2

here:

if(suitcase.shorts=true)

a single equal sign means assign, not check if equal

in the end, it matters if the if condition evaluate to true, so:

if(true)

is perfectly valid, so is:

x = true
if(x)

you can even assign a boolean value to a variable in the condition, like you did


#3

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