Testing Objects for Properties!

Testing Objects for Properties!
0

#1

Tell us what’s happening:
help me with this.Is there possible to code the without using if/else/switch

Your code so far

// Setup
var myObj = {
  gift: "pony",
  pet: "kitten",
  bed: "sleigh"
};

function checkObj(checkProp) {
  // Your Code Here
var result;  
result=myObj[checkProp];  
  return result;
}





  // Test your code by modifying these values
checkObj("house");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36.

Link to the challenge:


#2

Yes, you could use the ternary operator