Created
August 11, 2015 02:58
-
-
Save svahora/4f14604d86b7bd86e5b1 to your computer and use it in GitHub Desktop.
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) { | |
var GM = 398600.4418; | |
var earthRadius = 6367.4447; | |
var newArr = []; | |
arr.forEach(function(body) { | |
var a = earthRadius + body.avgAlt; | |
var t = Math.round(2*(Math.PI)*Math.sqrt(Math.pow(a, 3)/GM)); | |
newArr.push({name:body.name, orbitalPeriod:t}) | |
}) | |
return newArr; | |
} | |
orbitalPeriod([{name : "sputkin", avgAlt : 35873.5553}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment