Possible Copy Error in Javascript Challenge Guide

I may have found a copy discrepency in " freeCodeCamp Challenge Guide: Map the Debris"

I would appreciate it if someone could check this out to confirm or correct my reading of the solution/explanation. If I’m reading this right please point me in the direction to report it. Solution 2 for the same challenge has a similar wording.


In the Code Explanation for Solution 1 the last bullet states:

  • Then we delete the key avgAlt , and add the new key and its value.

it seems that the code actually is creating a new array of objects and doesn’t mutate the array. Should line should be corrected to something along the lines of

  • Then we add the new key: value and return the newArr.

This is the Solution in question:

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  var a = 2 * Math.PI;
  var newArr = [];

  var getOrbPeriod = function(obj) {
    var c = Math.pow(earthRadius + obj.avgAlt, 3);
    var b = Math.sqrt(c / GM);
    var orbPeriod = Math.round(a * b);
    // create new object
    return {name: obj.name, orbitalPeriod: orbPeriod};

  for (var elem in arr) {

  return newArr;

// test here
orbitalPeriod([{ name: "sputnik", avgAlt: 35873.5553 }]);

Code Explanation

Code Explanation

  • GM and earthRadius are both given to us.
  • To make the code easier to edit and read, each part of the equation is written separately.
  • Create newArr to store the orbPeriod 's.
  • a is 2 times pi. The part that is a constant is on the global scope while the rest is part of a function.
  • Create a function, gerOrbPeriod() that will do the required work for any amount of objects.
  • c is ( earthRadius + avgAlt ) to the cube.
  • b is the square root of c divided by GM .
  • Create orbPeriod to store the product of a and b , with the Math.round() function applied to round up to the next whole number.
  • ----->>>Then we delete the key avgAlt , and add the new key and its value.

Yep, that seems like a mistake, like the description of a slightly different solution. It looks closer to solution 3. You could create an issue on the repo.

as the solutions are on the forum guide, I have just moved your post in #contributors, where all guide contributions posts are kept, someone will come along and make the change :+1:

1 Like

Great. Thanks A lot.

Fantastic, Thank you.