Created
December 8, 2015 20:39
-
-
Save clive-bunting/82711ee792655223bedd to your computer and use it in GitHub Desktop.
Bonfire: Map the Debris
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
| // Bonfire: Map the Debris | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-map-the-debris | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function orbitalPeriod(arr) { | |
| var GM = 398600.4418; | |
| var earthRadius = 6367.4447; | |
| var results = []; | |
| for(var i = 0; i < arr.length; i++) { | |
| var semiMajorAxis = earthRadius + arr[i].avgAlt; | |
| var T = Math.round( 2.0 * Math.PI * Math.sqrt( Math.pow(semiMajorAxis, 3) / GM )); | |
| results.push({name: arr[i].name, orbitalPeriod: T}); | |
| } | |
| return results; | |
| } | |
| orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment