Tell us what’s happening:
question ask to modify given code which is short if else statement as per below. But solution requires to build object with different values and even though I build it and tested positively solution does not accept it, therefore you cannot pass this topic.
question asks for:
function checkObj(obj, checkProp) {
if(obj.hasOwnProperty(checkProp)) {
return obj.checkProp;
} else {
return "Not Found";
}
}
Solution requires below:
Your code so far
var myObj = {
"gift": "pony",
"pet": "kitten",
"bed": "sleigh",
"city": "Seattle"
};
function checkObj(checkProp) {
// Your Code Here
myObj.hasOwnProperty(checkProp);
return myObj[checkProp] || "Not Found";
}
// Test your code by modifying these values
console.log(checkObj("district"));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36
.
Challenge: Testing Objects for Properties
Link to the challenge:
neither is accepted