Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.   function injectNames(obj) {
  3.  
  4.     if (obj.hasOwnProperty("children")) {
  5.    
  6.       for (var property in obj) {
  7.  
  8.         //console.log("injectNames: " + property);
  9.        
  10.         for(var i = 0; i < obj.children.length; i++)
  11.         {
  12.          
  13.           if(obj.children[i] === obj[property])
  14.           {
  15.               obj.children[i].name = property;
  16.               break;
  17.           }
  18.        
  19.         }        
  20.  
  21.       }
  22.        
  23.     }
  24.    
  25.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement