Tell us what’s happening:
I wrote this code for this challenge and it’s not passing any test cases even though I’m getting the output as mentioned in test cases when I run the code in Repl.it.
Please have a look and tell me what’s wrong.
Your code so far
function orbitalPeriod(arr) {
var pii = Math.PI;
root = (arg) => Math.sqrt(arg)
formula = (a, mu) => 2*pii*root((Math.pow(a, 3))/mu);
var GM = 398600.4418;
var earthRadius = 6367.4447;
for(var i = 0; i < arr.length; i++){
var a = earthRadius + arr[i].avgAlt;
var mu = GM;
var val = Math.round(formula(a, mu));
delete arr[i]["avgAlt"];
arr[i]["orbitalPeriod"] = val;
}
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/77.0.3865.120 Safari/537.36.
Challenge: Map the Debris
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris