Tell us what’s happening:
My value is still far of the solution. And, how can I take update the object? I want to remove avgAlt and set orbitalPeriod.
How may I set a new property in arr?
Your code so far
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
for(let i=0;i<arr.length;i++){
let orbitalPeriod= Math.sqrt(4*Math.pow(Math.PI,2)+(earthRadius+arr[i]["avgAlt"]/(GM)))
delete arr[i]["avgAlt"];
return arr,orbitalPeriod
}
}
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36
.
Challenge: Map the Debris
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Your orbital period calculation is very wrong. What formula are you using?
1 Like
squareroot(4pi^2+(earthRadius+averAlt)/gm))
I don’t see that formula on the Wikipedia article anywhere. What about this formula
1 Like
How can I do with that a? That is the orbit, but i have the average altitude and Earth ratio. Does myself has to add them?
That is he equation that I used.
That is the same formula, but you did not code it correctly.
There is no cubed value in your code, you have an extra addition in the numerator in place of an multiplication, and you are not dividing the entire numerator by gm
.
You would calculate the a
the same way you computed r
.
1 Like
How may I set a orbitalPeriod in the object. I tried with push, but it is next to the object. It is not inside the object.
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let arreglo=[]
for(let i=0;i<arr.length;i++){
let orbitalPeriod=Math.round(Math.sqrt(4*Math.pow(Math.PI,2)*Math.pow((earthRadius+arr[i]["avgAlt"]),3)/(GM)))
delete arr[i]["avgAlt"];
}
}
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let arreglo=[]
for(let i=0;i<arr.length;i++){
let orbitalPeriod=Math.round(Math.sqrt(4*Math.pow(Math.PI,2)*Math.pow((earthRadius+arr[i]["avgAlt"]),3)/(GM)))
arreglo.push({name: arr[i]["name"],orbitalPeriod})
}
return arreglo
}
orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]);
I am thankful for your time