Testing Objects for Properties needs clarification.
See original GitHub issueChallenge Testing Objects for Properties has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
// Setup
var myObj = {
gift: "pony",
pet: "kitten",
bed: "sleigh"
};
function checkObj(checkProp) {
if(myObj.hasOwnProperty(checkProp)){
return myObj[checkProp];
}
return "Not Found";
}
// Test your code by modifying these values
checkObj("gift");
edited by mod
Issue Description
Clarity issue on this problem - User allowed to use dot operator to access value. however using dot operator(obj.prop NOT obj.“prop” as given in the paramater) in this instance creates undefined value - out of scope of this exercise
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Basic JavaScript: Testing Objects for Properties
Modify the function checkObj to test if an object passed to the function ( obj ) contains a specific property ( checkProp )....
Read more >Can someone clarify "Testing Objects for properties" for me ...
Okay, so I understand that this is checking if myObj has it's property of "top" or "middle" or whatever. Below is the task...
Read more >javascript (Testing objects for properties)
Now, using Conditional (ternary) Operator we need to check if the required property in the object is found or not.
Read more >Basic JavaScript Lesson:Testing Objects for Properties
Certification: JavaScript Algorithms and Data StructuresCourse: Basic JavaScriptLesson: Testing Objects for PropertiesfreeCodeCamp tutorialIn ...
Read more >Testing Objects for Properties in JavaScript - YouTube
By watching this video, you will learn how to test objects for properties in JavaScript. The platform used throughout this video is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @mszaf @rdsandovalm my code is working find for all the values. var myObj = { gift: “pony”, pet: “kitten”, bed: “sleigh” };
function checkObj(checkProp) { // Your Code Here if (myObj.hasOwnProperty(checkProp)){ return myObj[checkProp]; } else{ return “Not Found”; } }
// Test your code by modifying these values checkObj(“pet”);
Its really weird that its showing error for using .operator instead of [] while accessing the values of myObj. I searched online and everywhere it saying we can access property of a object in two ways:-
Hi @mszaf! Thank you for reporting this issue.
It took me a bit to understand what you were saying, so to save others the same struggle, here’s what I believe this is about. This challenge does not mention how to return the value when it is present. Campers could try to return the value as
return myObj.checkProp
rather thanreturn myObj[checkProp]
The previous challenge talks about the correct method, so I feel this is probably fine as it is.What do you all think?