Map the Debris - Help needed :/

Tell us what’s happening:

Can’t pass the challenge even though returned value is correct. I would really appreciate if someone could point out my mistake. Thanks!

Your code so far

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
	for (var i=0; i<arr.length; i++) {
  var a = arr[i].avgAlt + earthRadius;
  let periood = Math.round(Math.sqrt((Math.pow(a, 3) / GM)) * 2 * Math.PI);

  Object.defineProperty(arr[i], "orbitalPeriod", {
    value: periood

  delete arr[i].avgAlt;  
  return arr;

orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])

Your browser information:

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

Link to the challenge:

You’re missing the orbitalPeriod in your returned value.

1 Like


Thanks for the reply! Not sure what you mean exactly since the returned array has correct orbitalPeriod values according to console. The values in the pic are printed due to “console.log(arr)” at the end of the code.

When I run the code that you provided above, I see only the names.

1 Like

I am actually super confused now.

If you look at the console of the link provided, you can see the correct returned values.

Something about the Object.defineProperty isn’t working. It may have to do with the code editor? (I say that because I think that FCC and both use tha manaco editor). If I change that to just

arr[i].orbitalPeriod = periood;

it works.

1 Like

Of course my solution was unnecessarily complicated, I forgot you can add properties this way as well. It’s strange that freecodecamp’s console printed the correct result with my original code. Oh well…

Anyways, thank you for your time :slight_smile:!