# Map The Debris Challenge, need help w/ Last part

I was able to obtain the Orbital Period T in seconds and replace the aveAlt with orbitalPeriod and its associated value, but I’m struggling with how to iterate and replace aveAlt in an array with more than one Object. First test passes but second fails. I’ve tried using a for loop but haven’t had success yet…

``````function orbitalPeriod(arr) {
var GM = 398600.4418;

function orbitalPeriodT ( arr ) {
let a = earthRadius + arr[0].avgAlt;
let aPow = (Math.pow(a, 3));
let SqaGM = Math.sqrt(aPow / GM);
let T = 2 * Math.PI * SqaGM;
return Math.round(T);
}

arr[0].orbitalPeriod = orbitalPeriodT(arr);
delete arr[0].avgAlt;

return arr;

}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
``````

You said you tried with the for loop, but where it is?

I removed the original for loop and am now trying a for in loop using arr[key], which seems to be giving me some results but haven’t worked it all out yet.

If you want help with the loop, show what you have tried!

This is still a work in progress. I realize now I need to set arr[0] as arr[key].aveAlt and use it in a for loop along with the rest of the equations. This is what I am playing with. Doesn’t output anything yet. This is just adding the ability to see the aveAlt numbers in their own array. Since I can do that, I should be able to grab/loop through each arr[key].aveAlt number and then use it to solve for new number and re-insert somehow.

``````function orbitalPeriod(arr) {
var GM = 398600.4418;

function orbitalPeriodT ( arr ) {
let a = earthRadius + arr[0].avgAlt;
let aPow = (Math.pow(a, 3));
let SqaGM = Math.sqrt(aPow / GM);
let T = 2 * Math.PI * SqaGM;
return Math.round(T);
}

let newArr = [];
for (let key in arr) {
arr[key].avgAlt;
newArr.push(arr[key].avgAlt);
}

console.log(newArr);
//return arr;

}
``````