Map the debris (Freecodecamp Advanced algorithm 8)

Source: Internet
Author: User
Tags pow

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.