Created
June 30, 2022 13:41
-
-
Save juareznjunior/d9ed94436b559211b990167de7c7bc72 to your computer and use it in GitHub Desktop.
orbital period
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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