Map The Debris - Code returning right values but not passing tests

Map The Debris - Code returning right values but not passing tests
0

#1

Okay, so I have pasted my code below, and I need some help figuring this out I’m not looking for a code solution. I’ve handled all the calculations and the values returned are correct. The only difference I have noted is that the expected results all have unquoted Object keys, I don’t even know if that’s possible.

var GM = 398600.4418;
var earthRadius = 6367.4447;


function orbitalPeriod(arr) { 
  var finalArr = [];
  
  arr.forEach(function(obj){
    let OP = orbitalP(obj.avgAlt);
    delete obj.avgAlt;
    obj.orbitalperiod = OP;
    finalArr.push(obj);
  });
  
  
  return finalArr;
}

function orbitalP(alt){
  var OR = earthRadius + alt;
  var OP = 2 * Math.PI * (Math.pow((Math.pow(OR, 3)/GM),0.5));
  return Math.round(OP);
}  

So that’s my code, it works fine but I just can’t seem to pass the tests. Any assistance is welcome.


#3

Thank you for the response. I have just tried to move the variables inside, still not working.


#4

Oh my. Fixed it. turns out I didn’t camelCase obj.orbitalperiod that’s why I couldn’t pass the tests lol. this is embarrassing. Once i put obj.orbitalPeriod everything worked lol.


#6

Hahahaha amateur hour