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
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
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
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.
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}]);
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