Incorrectly working function. How to fix?

Only started to study JavaScript. Write the parser to understand and to fill the hand, for download mp3. To download a single track you need to open a separate tab. I want to automate this process, everything works until the loop/in. There is an assumption that by the time the loop has not yet been downloaded and therefore a nested function getA. But I'm not sure. Tell me, please. what's wrong

function getMP3(){
 var mp3 = []; // the output I want to receive this array with direct links
 objTraks var = getObject() // Object with links to each individual page of the track

 function getA(){
 var links = document.getElementsByTagName("a");
 links = Array.prototype.filter.call(links, function(x){
 return x.outerHTML.indexOf(".mp3") != -1;
 }); // Returns a filtered array of objects 
 mp3.push(links[0]['href']); 
}

 // !!!In this cycle the problem!!!
 for(var prop in objTraks){
 var w = window.open(objTraks[prop]); // Opens the page of the track 
 w.getA = getA.bind(w); // Not sure 
w.getA();
w.close();
}
 mp3 return; // Now returns an empty array.
 }
July 4th 19 at 23:18
0 answer

Find more questions by tags JavaScript