0

I have this function to check and return the value if key is equal to object key.

for example key is code and object have {'code':'123', 'name':'mokee'}, so in this case function should return 123. But below code condition is working but return always null.

 hasSameProps( prop, obj ) {
        let keys = Object.keys( obj )
         keys.forEach(function(key){
          if(key===prop){
            return obj[key];
          }
         });
        return null;
      }
boycod3
  • 5,033
  • 11
  • 58
  • 87

0 Answers0