Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save 12afaelPereira/4a875291402869228e309ee434b36b54 to your computer and use it in GitHub Desktop.
Save 12afaelPereira/4a875291402869228e309ee434b36b54 to your computer and use it in GitHub Desktop.
function orbitalPeriod(arr) {
let GM = 398600.4418;
let earthRadius = 6367.4447;
let T;
arr.map( (item, index) => {
item.orbitalPeriod = Math.round( 2 * Math.PI * (Math.sqrt( Math.pow(earthRadius+arr[index].avgAlt , 3) / GM)) )
})
arr.map(item => delete item.avgAlt)
return console.log(JSON.stringify(arr))
}
//orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment