What is the reason for my code to not work on the Map the Debris challenge?

What is the reason for my code to not work on the Map the Debris challenge?
0.0 0

#1

Tell us what’s happening:
I am trying to figure out why I can’t pass the challenge with my solution. I feel like my solution does everything correctly. Can anyone point out what I am doing wrong here? Thanks!

Your code so far


function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  
  var orbital = 2 * Math.PI * Math.sqrt(earthRadius + (Math.pow(arr.avgAlt, 3)/GM));

  arr.pop();

  arr.push({oribtalPeriod: orbital});

  return arr;
}

orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris


#2

First of all, your formula for orbital produces NaN. You have a logic issue with your formula. My suggestion is to break the large formula into smaller pieces and console.log each piece so you can validate the piece matches what it should if you manually calculated the piece on paper or using a calculator.

EDIT: One small hint here is think about what value arr.avgAlt is. If you are not sure, then console.log(arr.avgAlt) to find out. I think you will be surprised.

Secondly, you are supposed to return a new array and not mutate the original array passed into the function.