Skip to content

Instantly share code, notes, and snippets.

@svahora
Created August 11, 2015 02:58
Show Gist options
  • Save svahora/4f14604d86b7bd86e5b1 to your computer and use it in GitHub Desktop.
Save svahora/4f14604d86b7bd86e5b1 to your computer and use it in GitHub Desktop.
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