Skip to content

Instantly share code, notes, and snippets.

@juareznjunior
Created June 30, 2022 13:41
Show Gist options
  • Save juareznjunior/d9ed94436b559211b990167de7c7bc72 to your computer and use it in GitHub Desktop.
Save juareznjunior/d9ed94436b559211b990167de7c7bc72 to your computer and use it in GitHub Desktop.
orbital period
function orbitalPeriod(arr) {
const GM = 398600.4418;
const earthRadius = 6367.4447;
return arr.map(obj => {
return {
"name": obj.name
,"orbitalPeriod": Math.round(2 * Math.PI * Math.sqrt(Math.pow(earthRadius + obj.avgAlt, 3) / GM))
}
});
}
console.log(orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment