# Map the Debris Help

**URL:** <https://forum.freecodecamp.org/t/map-the-debris-help/447332>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [February 20, 2021, 1:58am UTC](https://forum.freecodecamp.org/t/map-the-debris-help/447332 "2021-02-20T01:58:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwr318](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwr318/32/169843_2.png) [@jwr318](https://forum.freecodecamp.org/u/jwr318)\
**Post date:** [February 20, 2021, 1:58am UTC](https://forum.freecodecamp.org/t/map-the-debris-help/447332/1 "2021-02-20T01:58:09Z")

</div>

**Tell us what’s happening:**

When I checked the output, it had the correct output answer but its not registering in Freecodecamp. What have I done wrong?

```
  **Your code so far**

```

```js

function orbitalPeriod(arr) {
var GM = 398600.4418;
var earthRadius = 6367.4447;
let args = [...arr]
let orbits = [{
  name: "",
  orbitalPeriod: ""
}];
let newArray = []

for (let i = 0 ; i <= arr.length; i++){
  if (args.length){
    let isolate = args.pop()
    let answer = Math.round(Math.sqrt((4 * Math.pow(Math.PI, 2) * Math.pow(earthRadius + isolate.avgAlt , 3))/GM))
    let newObj = Object.create(orbits)
    newObj.name = isolate.name
    newObj.orbitalPeriod = answer;
    newArray.unshift(newObj)
  }
}
return newArray
}

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/88.0.4324.182 Safari/537.36`.

**Challenge:** Map the Debris

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/map-the-debris)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![jwr318](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwr318/32/169843_2.png) [@jwr318](https://forum.freecodecamp.org/u/jwr318)\
**Post date:** [February 20, 2021, 2:13am UTC](https://forum.freecodecamp.org/t/map-the-debris-help/447332/2 "2021-02-20T02:13:41Z")

</div>

I looked through the forum and saw the method to avoid creating a temporary obj by deleting the arr.avgAlt. I modified my original code to incorporate delete avgAlt and that worked. I still don’t understand why my answer didn’t register as accurate. Perhaps it was the creation of new object instances ?

---

<div class="post-metadata">

**Author:** ![jenovs](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jenovs/32/60963_2.png) [@jenovs](https://forum.freecodecamp.org/u/jenovs)\
**Post date:** [February 20, 2021, 3:43am UTC](https://forum.freecodecamp.org/t/map-the-debris-help/447332/3 "2021-02-20T03:43:07Z")

</div>

The problem is with this part:

```auto
let orbits = [{
  name: "",
  orbitalPeriod: ""
}];

```

If you remove the wrapping array your code will work.

Btw, you can avoid Object.create if you just use:

```auto
let newObj = { name, orbitalPeriod: answer };

```

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [August 21, 2021, 3:43pm UTC](https://forum.freecodecamp.org/t/map-the-debris-help/447332/4 "2021-08-21T15:43:23Z")

</div>

Closed on August 21, 2021, 3:43pm UTC

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