1/2 Checked for Map the Debris

Tell us what’s happening:
Got 1 /2 checked, can’t seem to iterate to more keys.

Am I even going the right direction with this code?

I Hope, someone could help. It will be a great help.

Cheers~~

Your code so far


function orbitalPeriod(arr) {
for (let i in arr)  {
    var a = 6367.4447 + arr[i].avgAlt;
    var GM = 398600.4418;
    var a_3 = Math.pow(a, 3);
    var pi_2 = 2*Math.PI;
    var sqrt = Math.sqrt(a_3/GM)
  for (let j in arr) {
    arr[j].orbitalPeriod = Math.round(pi_2*sqrt);
    delete arr[j].avgAlt;
    }
  return arr;
  }
};


console.log(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/80.0.3987.149 Safari/537.36.

Challenge: Map the Debris

Link to the challenge:

There are two things that can cause problems for you currently. Take a look at the placement of the return statement. After that look at the second loop and consider if second loop is really needed.

1 Like

Thanks! got it.

Cheers~~