11 lines
No EOL
357 B
JavaScript
11 lines
No EOL
357 B
JavaScript
function orbitalPeriod(arr) {
|
|
var GM = 398600.4418;
|
|
var earthRadius = 6367.4447;
|
|
arr.forEach(element => {
|
|
element.orbitalPeriod = Math.round(2 * Math.PI * Math.sqrt(Math.pow(earthRadius + element.avgAlt, 3) / GM));
|
|
delete element.avgAlt;
|
|
});
|
|
return arr;
|
|
}
|
|
|
|
console.log(orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])); |