Facebook
From Sole Macaque, 1 Week ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 39
  1. // Dear Bean,
  2. // I used an if/else because the tests in the bottom left always return the value of the property
  3. // like pet: "kitten" (if it is found on obj) or "Not Found" (else).
  4. // I copied the snippet for obj[checkProp]; to read the value of the object property from the lesson before. xD
  5. // Have a nice day.
  6.  
  7. if (obj.hasOwnProperty(checkProp)){
  8.   return obj[checkProp];
  9. }
  10. else{
  11.   return "Not Found"
  12. }
  13.  
  14. // https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/testing-objects-for-properties