Map the debris question


When I put the test questions into my program I receive the correct output, but my values in the result:

[ { name: ‘iss’, orbitalPeriod: ‘5557’ },
{ name: ‘hubble’, orbitalPeriod: ‘5734’ },
{ name: ‘moon’, orbitalPeriod: ‘2377399’ } ]

which seems to be the correct numbers, but the array has strings for the orbital period values. how do I keep them as numbers when they are added to the object.

Thank you.

  **Your code so far**

function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let newArr =[]

for(let i =0; i<arr.length; i++){
  arr[i].orbitalPeriod = calc(arr[i])
  delete arr[i].avgAlt

function calc(obj){
  let obPer= Math.sqrt(Math.pow((earthRadius+obj.avgAlt),3)/GM)*2*Math.PI
  let obPerRnd = Number.parseFloat(obPer).toFixed(0)
  return obPerRnd

return arr;


orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);
console.log(orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}]))
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36.

Challenge: Map the Debris

Link to the challenge:

To fixed actually converts to a string with a fixed number of digits. I’d look at Math.round

Thank you very much!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.