Hi everyone.
I´m doing Basic JavaScript: Testing Objects for Properties and I can´t pass the test. I´ve test my code in other javascript editor and when I add this lines:
var result = checkObj("man");
document.writeln(result);
the result is “No found”. If I try with “gift”, result is “pony”. It looks like it´s working, right? It´s not. I can´t pass the test.
Could you please tell me what I´m doing wrong and why it works in other editor?
Thank you.
Your code so far
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
var test = myObj.hasOwnProperty(checkProp);
if (test == true) {
return myObj[checkProp];
}
else {
return "Not Found"
}
}
// Test your code by modifying these values
checkObj("man");
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties