Orbital period test

Tell us what’s happening:
Describe your issue in detail here.

hi everyone I’m not seeming to get the orbital period from the one the tests showing. i confirmed on wikipedia and some physics textbooks taht my equations and variables are correct;

var acubedOverGM = (aCubed/GM);
5056.601781444493

  **Your code so far**

function orbitalPeriod(arr) {

var GM = 398600.4418;
var earthRadius = 6367.4447;
var twoPie = 2*Math.PI;
var aCubed = Math.pow(earthRadius,3);
var acubedOverGM = (aCubed/GM);

var T = twoPie*(Math.sqrt(acubedOverGM));
console.log(T)

return arr;
}

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/92.0.4515.131 Safari/537.36

Challenge: Map the Debris

Link to the challenge:

I don’t see anywhere that you have added code to make a new array with the required information and return this new array?

1 Like

im not at that part yet. im just at the variable initialization. and the calculating. im getting that 5000 from console.log but the correct calculation suppose to be 88k

Have you checked the value of GM? Also, where is the orbital altitude of the satellite?

the gm is given here

var GM = 398600.4418;

1 Like

from my understanding the orbital altitude or the avg alt that was in the parameter wasnt part of the equation. all we needed was the gm and radius. i thought its the orbital altitude we are replacing with the orbital period

The average altitude is a critical part of the equation. You cannot compute the orbital period without the size of the orbit.

oh ok. makes sense. i will peruse through my old physics books

This may be useful

thank alot, I just figured it out. helps when i read it thoroughly rather than skimming . im sure you’ll hear from me again once i get into the coding part.

1 Like

It’s a tricky formula

how do you delete a property from an object? this delete function doesnt seem to work.


  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var twoPie = 2*Math.PI;
  var aCubed = Math.pow(earthRadius+35873.5553,3);
  var acubedOverGM = (aCubed/GM);
  var T = twoPie*(Math.sqrt(acubedOverGM));


  T=Math.round(T)
  arr.orbitalPeriod=T;
  delete arr.avgAlt;
  console.log(arr)
  

  return arr;
}

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

delete works, but arr is not the object, so it doesn’t have the avgAlt property

ok that make sense, now it kinda make sense, when it said return a new array . im taking a hint it wants you to create a new object with the new values to return.

im very close but cant seem to get the second test to pass.

herer is my code with the new Array.

function orbitalPeriod(arr) {
  let newArray = [];
  

  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var twoPie = 2*Math.PI;
  var aCubed = Math.pow(earthRadius+35873.5553,3);
  var acubedOverGM = (aCubed/GM);
  var T = twoPie*(Math.sqrt(acubedOverGM));
  T=Math.round(T)
  
let obj = {};
obj.name='sputnik';
obj.orbitalPeriod=T;
newArray.push(obj)

 
  return newArray;
}

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

im sure theres something else i need t o do . but im not certain what

you are hardcoding the name of the space object, instead your code should use the function parameter arr, and gives an output of an array with inside an object for each element inside the function parameter arr

got it but since the object in the function parameter isnt like a typical object, how do i access the object values. to do the calculations. i tried arr.altvalue and it doesnt work . that was why i tried to hardcode an object using those parameters. and create a new array

The function parameter is no object, it’s an array of objects. You can loop over the array to get access to the objects inside.

thanks alot. i figured it out. I used the map method with an arrow function. and it worked.