Map the debris
Returns an array whose contents convert the average elevation of the corresponding element in the original array to its corresponding orbital period.
The original array contains the formatted object content, like this {name: ‘name‘, avgAlt: avgAlt}
.
A formula for calculating orbital periods with orbital heights
A: Half-length axis of the track (m),μ = GM
The value to be evaluated should be the nearest integer, and the orbit is based on the earth.
The earth radius is 6367.4447 kilometers, the Earth's GM value is 398600.4418, pi is Math.PI
function Orbitalperiod (arr) {varGM =398600.4418; varEarthradius =6367.4447;varRetarr = []; function Calorbital (avgalt) {returnMath.Round (2* Math.PI * (math.sqrt (Math.pow (Avgalt + Earthradius,3)/GM)); //return Math.Round (Math.pow (((Math.pow (Math.PI, 2) * MATH.POW ((Avgalt+earthradius), 3 )),/gm)); } for(varI=0; i<arr.length;i++){ varobj = {}; Obj.name=Arr[i].name; Obj.orbitalperiod=calorbital (Arr[i].avgalt); Retarr.push (obj); } returnRetarr; } orbitalperiod ([{name:"Sputnik", Avgalt:35873.5553}]);
Map the debris (Freecodecamp Advanced algorithm 8)