Tell us what’s happening:
The output of my function looks correct to me, but I’m failing the second test. Am I missing something obvious? I can’t tell what is wrong on my code.
**Your code so far**
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
function objPeriod(altitude) {
return Math.round((Math.sqrt(Math.pow((earthRadius + altitude), 3) / GM)) * 2 * 3.14159)
}
return arr.map(obj =>({name: obj.name, orbitalPeriod: objPeriod(obj.avgAlt)}));
}
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
**Your browser information:**
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:78.0) Gecko/20100101 Firefox/78.0.
Nope, I was wrong, my function returns an array as expected. Still haven’t a clue of what is wrong. I could really use an hint, don’t want to look at the solution yet. Thanks!
the last digit of the moon period is wrong - this is a maths issue, your PI has 6 significant digits, meaning it will give only 6 significant digit to your result - the moon period has 7 digits, outside of that safe range of 6 digits and in fact the last digit is the wrong one.