Tell us what’s happening:
I want to round the value to the nearest whole number.

I have input 2377396.9654660705
Output have to be - 2377399

I can’t understand how to we have to get 2377399

Your code so far

```
function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
var newArray = [];
for (let i = 0; i < arr.length; i++) {
var avgAlt = arr[i].avgAlt;
var r = earthRadius + avgAlt;
var orbitalPeriod = (2 * 3.14159 * Math.sqrt(r * r * r / GM));
newArray.push({ 'name': arr[i].name, 'orbitalPeriod': orbitalPeriod});
}
return newArray;
}
console.log(orbitalPeriod([{ name: "iss", avgAlt: 413.6 }, { name: "hubble", avgAlt: 556.7 }, { name: "moon", avgAlt: 378632.553 }]));
```

Challenge: Map the Debris

Link to the challenge:

Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.

ilenia
October 26, 2020, 12:19pm
#2
`parseInt`

was introduced in the curriculum

but there are also `Math.floor`

, `Math.round`

and `Math.ceil`

, which where also mentioned somewhere

ilenia:

Math.floor

Sorry, but we when do this `parseInt(2377396.9654660705)`

We get output `2377396`

, but we want 2377399

ilenia
October 26, 2020, 12:24pm
#4
you can`t get an ending with 9 at all from that number, or 6 or 7 depending on which method you use to round

1 Like

Then, how to we have to get 2377399 in challenge?
With input 413.6 and 556.7 I get correct number but with 2377399 I can’t figure out

Yes, this is test and above my code

orbitalPeriod([
{name: “iss”, avgAlt: 413.6},
{name: “hubble”, avgAlt: 556.7},
{name: “moon”, avgAlt: 378632.553}
])

ilenia
October 26, 2020, 12:31pm
#8
could be a precision issue, yor value of PI may be bringing precision down. use `Math.PI`

instead

1 Like

ilenia:

Math.PI

Thank you, that’s help me!

ilenia
October 26, 2020, 12:33pm
#10
the issue is that the max precision in multiplication is given by the number with the lowest amount of cifres, with that case, the PI value had a lower number of cifres than the input number

Odefo
October 27, 2020, 3:29am
#11
Kindly wrap the output with Math.ceil() , i think that should solve the problem