Create array of arrays or something similar (review solution)
  {
   playerId: 1,
   name: Cristiano,
   lastName: Ronaldo,
   age: 37
  }
Also, suppose I run a for each loop that gets the id of each player_api and returns me the record with that id in the database (player_database).
So, I have a player_api and the respective player_database. Now, I want to create an array/object of the form (or similar to): [[player_api_id1, player_database_id1], [player_api_id2, player_database_id2], [player_api_id3, player_database_id3]] that associates each player_api with the respective player_database.
Â
My solution, for each API call:Â
1. Create a main variable (var_1)
2. Create a second variable (var_3)
3. In the for each loop, 1. add to end of var_3: player_API AND player_database
2. add to end of var_1: var_3
3. Empty var_3
4. var_1 should now contain the list of lists.
[image.png]
My questions:
1. Â Is this the method you would use to fulfill this objective (i.e. store these tuples of api and database data)? I am not very accustomed to objects, but could they be a better solution for this case?
2. var_1 and var_3 are created after each API call. Where do they go once a new API is called? Are they deleted from the system?
Thank you.
Other
6 replies