Tianhe Gao

map-the-debris

  1. [Intermediate Algorithm Scripting: Map the Debris | freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris)
  2. [freeCodeCamp Challenge Guide: Map the Debris - Guide - The freeCodeCamp Forum](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-map-the-debris/16021)

答案

```js function orbitalPeriod(arr) { const GM = 398600.4418 const earthRadius = 6367.4447 const a = 2 * Math.PI const newArr = []

const getOrbPeriod = function (obj) { const c = Math.pow(earthRadius + obj.avgAlt, 3) const b = Math.sqrt(c / GM) const orbPeriod = Math.round(a * b) return { name: obj.name, orbitalPeriod: orbPeriod } }

for (let elem in arr) { newArr.push(getOrbPeriod(arr[elem])) }

return newArr }

console.log(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }])) ```


No notes link to this note