Try to debug your code with console.log() instead of alerts. Then you will see the following (open the browsers console with F12. To push the inner object to an array, you can just use Array.prototype.push().