8/30 Am I doing something wrong?


#1

the instructions say: Remove the console.log statement.

Write an if statement that checks to see if suitcase has the shorts property.

If your if statement evaluates to true, print the value of the shorts property.

If your if statement evaluates to false, set the shorts property to any value you wish using dot notation. Then print the value of the shorts property.

My code is:

var suitcase = {
shirt: "Hawaiian"
};

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

It says the syntax is wrong.


#2

you missed a bracket in your if statement

if(suitcase.hasOwnProperty('shorts')**

)


#3

Close your if parameter with a bracket.

if (your parameter) {
...
}

#4

var suitcase = {
shirt: "Hawaiian"
};
if (suitcase.hasOwnProperty('shorts')) {
console.log('shorts')
} else {
suitcase.shorts = "Hakim";
console.log('shorts')
};