SHARE
TWEET

Untitled

a guest Jul 22nd, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```javascript
  2. function goodKeys(obj, callback) {
  3.   let array = [];
  4.   // loop through each property obj
  5.   for (let property in obj) {
  6.     // if the return value of the callback equals true
  7.     if (callback(obj[property]) === true) {
  8.       // then push key to array
  9.       array.push(property);
  10.     }
  11.   }
  12.   return array;
  13. }
  14. // Uncomment these to check your work!
  15. const sunny = { mac: 'priest', dennis: 'calculator', charlie: 'birdlaw', dee: 'bird', frank: 'warthog' };
  16. function startsWithBird(str) { return str.slice(0, 4).toLowerCase() === 'bird'; };
  17. console.log(goodKeys(sunny, startsWithBird)); // should log: ['charlie', 'dee']
  18. ```
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top