Dressed to impress; ReferenceError: Invalid left-hand side in assignment


#1


var suitcase = {
    shirt: "Hawaiian"
};

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

I got response :ReferenceError: Invalid left-hand side in assignment


#2

here:

if (suitcase.hasOwnProperty('shorts') = true)

a single equal sign means assign, to compare if equal use two or three equal signs


#3

thx a lot, it works :slight_smile:


#4