Returning strings vs returing values

Tell us what’s happening:
Describe your issue in detail here.
I’m not sure how to interpret “If the property is found, return that property’s value”
…later it says " checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift") should return the string pony " … 1. The tutorial up to this point never stated how to convert numbers variables into string representations (casting)…2. In real life outside the tutorial environment, does returning a string print it like console.log()?

  **Your code so far**

function checkObj(obj, checkProp) {
// Only change code below this line
if (obj.hasOwnProperty("checkProp")){
  return obj.checkProp;
return "Not Found";
// Only change code above this line
  **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:100.0) Gecko/20100101 Firefox/100.0

Challenge: Testing Objects for Properties

Link to the challenge:

You don’t need to, the values of the properties are always strings in this case

No, returning a value from a function means that when the function is called it is resolved as the output
If you want to print the return value of a function you need to use console.log

For example:

console.log(checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift"))

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.