Loop through objects

Tell us what’s happening:
I passed the first test, but I am not getting the second one right and I know it’s because I have to create a for loop. The problem is that I don’t know how to loop and select “avgAlt” and then delete it.

Your code so far


function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;

var PiTimesTwo = 2 * Math.PI;

var mathPowDivide = Math.pow(earthRadius + arr[0]["avgAlt"], 3) / GM;
var getTotal = Math.round(Math.sqrt(mathPowDivide) * PiTimesTwo);

//arr[0]["avgAlt"] = arr[0]["orbitalPeriod"] 
arr[0]["orbitalPeriod"] = getTotal;
delete arr[0]["avgAlt"];

if(arr[0].length === 3) {
  for(var i = 0; i < arr[0].length; i++) {
    //arr[0][i]["orbitalPeriod"] = getTotal;
  }
}

return arr;
}

console.log(orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]));


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36.

Challenge: Map the Debris

Link to the challenge:

now you have the logic to do this when you have one object

how do you loop through an array and apply the same logic to each element in the array? it is something you already did multiple times, this time seems different because you need to apply a complex logic