So I am having trouble understanding the formula to obtain the values of time orbitals. So far I have mapped the array of objects to extract the average altitude data and was looking to map again using the formula, however the values are not as they should be.

I presume the formula I am using is incorrect but I am not sure.

Thanks.

Your code so far

function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let results = arr.map(function(e) {
return e.avgAlt;
})
let orbitalPeriods = results.map(function (e) {
return 2 * Math.PI * Math.sqrt((earthRadius + e)/ GM)
})
console.log(orbitalPeriods)
}
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/87.0.4280.88 Safari/537.36.

After a few days off, I am back to tackling this challenge. So far, I have calculated the formula and deleted the avgAlt property. My thinking of how to add the new property would be to use for (let i = 0; i < arr.length; i++) { arr[i].orbitalPeriod = orbitalPeriods[0] however Im not sure how to iterate through the orbitalPeriods in order to add them. I tried using a nested loop with J but this did not work.

function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let results = arr.map(function(e) {
return e.avgAlt;
})
let orbitalPeriods = results.map(function (e) {
return Math.round(2 * Math.PI * Math.sqrt(Math.pow((earthRadius + e),3)/ GM))
})
arr.map(function (e){
delete e.avgAlt
})
for (let i = 0; i < arr.length; i++) {
arr[i].orbitalPeriod = orbitalPeriods[0]
console.log(arr[i])
}

you don’t need a nested for loop, if you have the logic to have the result for when you have only one object in the array, you can use that logic when there is more than one object using a loop or map to apply it to each of them and build the array output

it seems you are trying to do it, but I suggest you put all the logic in only one map method