JavaScript: add the JSON data of one JS object to another : In the function there is an empty JS object 

    var globalDataObject = [{}]; 

Then, there is a loop that goes over an array of users, stores the properties of each user in variables (ex. name, lastName) and creates an object for each user: 

    //create an object containing the current name 

    const currentObject = {
     'profile': {
         'name': nameVariable,
         'lastName': lastNameVariable
     }
    };

QUESTION: what is the right way to add the data of currentObject to the globalDataObject once it's created? So that at the end the globalDataObject should be: 

    var globalDataObject = [

    'profile': {
         'name': 'John',
         'lastName': 'Smith'
     }

    'profile': {
         'name': 'Ann',
         'lastName': 'Lee'
     }

    'profile': {
         'name': 'Dan',
         'lastName': 'Brown'
     }
    ]; 

Sorry if that's too simple but I really couldn't come up with the right way to do that. 
Important thing is that globalDataObject must be the JS object of the specified format (not the object containing multiple object and not the JSON array) since once it's created it is going to be converted into XML. 

Thank you for any help with this! 

    
    

