So i did everything right but i cant pass it for some reason.
Could you please post the code and a link to the challenge? Small screenshots saved on Imgur aren’t really a substitute.
The output has to be exactly as mentioned in the instructions. It’s case sensitive.
Tried with a variable but nothing.
https://www.freecodecamp.org/challenges/testing-objects-for-properties
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
var result = "";
if (myObj.hasOwnProperty(checkProp)) {
result = myObj[checkProp];
} else {
result = "Not found";
}
return result;
}
// Test your code by modifying these values
checkObj("gift");
Look closely at which test doesn’t pass and then compare the output of that test with your code.
Ok i just figured out where i failed lol, i was going too quick with lazy brain.
Haha, I think we have all made these mistakes. It’s good practice though, as sometimes you might make a casing mistake in your variables and wonder why the code isn’t working.
My biggest problem is when i dont pass the challenge on my own so i need to look up at hint, even though i understand code and way it works but i feel bad for having to check hint’s. Idk if therew any tips that helps with finding own solutions, i wonder how long does avg developer take to write code on his own with little to no help. I know im beginner, im still using 95% of times freecodecamp challenges and rest is w3schools to look up couple of small details.
Oh I really know your struggle. I’ve been in this for a little longer now, but in the beginning I used to really struggle with my confidence in judging my code and figuring out where it went wrong. I think this comes with a little more practice. Don’t give up, I’m sure you’ll do a great job eventually! Just allow yourself to learn in your own pace, even if that means looking at hints. You’ll soon find you will need them less. Small steps!
EDIT: I put checkprop in " " so nvm XDD
Hi! I seem to also have this problem but this code didn’t let me pass for some reason…
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
// Your Code Here
var result = "";
if(myObj.hasOwnProperty("checkProp")){
result = myObj[checkProp];
}else{
result = "Not Found";
}
return result;
}
// Test your code by modifying these values
checkObj("gift");
It passes the not found test but fails all else please help I have been working on it for DAYS.
Taking out the quotation mark on “checkProp” -> . checkProp
ya thanks! I noticed that a while back and got through the challenge.