Created
May 26, 2019 20:55
-
-
Save 12afaelPereira/4a875291402869228e309ee434b36b54 to your computer and use it in GitHub Desktop.
This file contains hidden or 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) { | |
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