день программы "#100 Days Of Code"
The array will contain objects in the format
{name: 'name', avgAlt: avgAlt}
.You can read about orbital periods on wikipedia.
The values should be rounded to the nearest whole number. The body being orbited is Earth.
The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km3s-2.
Here are some helpful links:
function orbitalPeriod(arr) { var GM = 398600.4418; var earthRadius = 6367.4447; var answer =[]; var radius; for (var i = 0; i < arr.length; i++){ answer[i]= {}; answer[i].name = arr[i].name; radius =earthRadius + arr[i].avgAlt; answer[i].orbitalPeriod = Math.round(2 * Math.PI *Math.sqrt((Math.pow(radius,3))/GM)); } return answer; } orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Ответы:
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])
return [{name: "sputnik", orbitalPeriod: 86400}].
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])
return [{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}].
Комментариев нет:
Отправить комментарий