Hello,
i am a little confused at the moment because of my syntax.
First it looked like this:
var suitcase = {
shirt: “Hawaiian”,
};
if(suitcase.hasOwnProperty(“shorts”)){
console.log(suitcase[shorts]);
}
else{
suitcase.shorts = “Badehose”;
console.log(suitcase[shorts]);
}
It always replied with an error.
Then i changed it to:
var suitcase = {
shirt: “Hawaiian”,
};
if(suitcase.hasOwnProperty(“shorts”)){
console.log(suitcase[shorts]);
}
else{
suitcase.shorts = “Badehose”;
** console.log(suitcase.shorts);**
}
and it works.
What’s the difference between the notation console.log(suitcase[shorts]); and console.log(suitcase.shorts);?
I thought it would be the same?
Thank you in advance.