Skip to content

Instantly share code, notes, and snippets.

// Bonfire: Map the Debris
// Author: @dfu23
// Challenge: http://www.freecodecamp.com/challenges/bonfire-map-the-debris?solution=function%20orbitalPeriod(arr)%20%7B%0A%20%20var%20GM%20%3D%20398600.4418%3B%0A%20%20var%20earthRadius%20%3D%206367.4447%3B%0A%20%20%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20arr.length%3B%20i%2B%2B)%20%7B%0A%20%20%20%20var%20answer%20%3D%20(Math.PI%20*%202)%20*%20Math.sqrt(Math.pow(earthRadius%20%2B%20arr%5Bi%5D.avgAlt%2C%203)%20%2F%20GM)%3B%0A%20%20%20%20delete%20arr%5Bi%5D.avgAlt%3B%0A%20%20%20%20arr%5Bi%5D.orbitalPeriod%20%3D%20Math.round(answer)%3B%0A%20%20%7D%0A%20%20%0A%20%20return%20arr%3B%0A%7D%0A%0AorbitalPeriod(%5B%7Bname%20%3A%20%22sputnik%22%2C%20avgAlt%20%3A%2035873.5553%7D%5D)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
for (var i = 0; i < arr.length; i++) {