I defined the function. if I’m not allowed to call the function how do I test it?
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)){
return checkProp
}
else {
return "Not found";
}
// Only change code above this line
};
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
But if you want to play around with the code and see what happens for yourself, I’d recommend playing around with the code in a separate environment, such as an IDE or repl.it
Thank you all for chiming in.
I found a solution in case someone comes across this
function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty(checkProp)){
return obj[checkProp];
}
else {
return "Not Found";
}
// Only change code above this line
};
Your code has been blurred out to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution. In the future, if you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.
you are not allowed to have extra code when running the tests
I usually add the function calls I need to test, and then delete those before running the tests