Guest User

Untitled

a guest
Jul 20th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. // search recursive for the id and return object
  2. getObject(data, id)
  3. {
  4. var result = null;
  5. for(var prop in data)
  6. {
  7. if(data[prop] instanceof Object)
  8. {
  9.  
  10. for(var index in data[prop].options)
  11. {
  12. if(data[prop].options[index].id == id)
  13. {
  14. return data[prop];
  15. }
  16. }
  17.  
  18. result = this.getObject(data[prop], id);
  19. if (result)
  20. {
  21. break;
  22. }
  23. }
  24. }
  25.  
  26. return result;
  27. }
Add Comment
Please, Sign In to add comment