**I have one question
Hey, how are ya all? I cant solve the problem: Map the Debris. I guess I need more comprehension on objects. Could someone debud the code below please? I think the problem is when trying to make an object out of two arrays: it is pretty hard.
Also, whats you timin on solving problems on intermediate scripting in JavaScript? I have got 2 hours to some 2 problems today and on average I spend 30 minutes on each one! If anybody can motivate me haha, please I need your help!
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
var avgAltarr = [];
var namesArr = [];
var resultOp = [];
var final =[];
//get the AvgAlt by a for loop arr[i].avgAlt
for(let i=0;i<arr.length;i++){
avgAltarr.push(arr[i].avgAlt);
}
//get the names into another array of same length
for(let i=0;i<arr.length;i++){
namesArr.push(arr[i].name);
}
//do the math to trasnform avgAlt into orbit period
for(let i=0;i<avgAltarr.length;i++){
resultOp.push(Math.round(2*Math.PI*Math.sqrt(Math.pow(avgAltarr[i],3)/GM)));
}
//unite namesArr and results into one object
for(var i=0;i<namesArr;i++){
final[i]= {name: arr[i].name, orbitalPeriod: resultOp[i]};
}
return final[i];
}
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
**
Thanks all you guys!
Challenge: Map the Debris
Link to the challenge: