Advertisement
Guest User

Untitled

a guest
Jan 24th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var teste1 = {id: "Nattan", category: "Categoria1"}
  2. var teste3 = {id: "Nattan2", category: "Categoria2"}
  3. var teste2 = {id: "Nattan3", category: "Categoria3"}
  4.  
  5.  
  6. var arr = { apps: [] }
  7. for(var i = 0; i < 3; i++){
  8.     var r = resultado(i);
  9.     arr.apps.push(r);
  10. }
  11.  
  12. console.log(arr);
  13.  
  14. function resultado(id){
  15.    
  16.     if(id == 0){
  17.         return teste1;
  18.     }
  19.    
  20.     if(id == 1){
  21.         return teste2;
  22.     }
  23.    
  24.     if(id == 2){
  25.         return teste3;
  26.     }
  27. }
  28.  
  29. /*
  30. { apps:
  31.    [ { id: 'Nattan', category: 'Categoria1' },
  32.      { id: 'Nattan3', category: 'Categoria3' },
  33.      { id: 'Nattan2', category: 'Categoria2' } ] }
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement