Solution Feedback - Map the Debris

Solution Feedback - Map the Debris
0.0 0

#1

My solution for this problem doesn’t match any of the listed solutions, so was looking for feedback if my solution has any meaningful issues. Thanks in advance!

Challenge: https://beta.freecodecamp.org/en/challenges/intermediate-algorithm-scripting/map-the-debris

function orbitalPeriod(arr) {
  var GM = 398600.4418;
  var earthRadius = 6367.4447;
  
  return arr.map(obj => ({name: obj.name, orbitalPeriod: Math.round(Math.sqrt(Math.pow(earthRadius + obj.avgAlt,3) / GM) * (2 * Math.PI))}));
  
}

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

#2

Actually, if you look at wiseman’s solution (the last one), it is basically the same as yours. The only difference is that you have reversed the placement of the 2 * Math.PI part.

I don’t see any issues with your solution. Which part of your solution are you concerned about specifically?


#3

I’ll check out the one you referenced. The ones that I looked at were deleting a property and adding a new property.

I didn’t have a specific concern…I was thinking that doing name: obj.name might have not been the best way to handle since nothing was really changing here. That felt a bit hardcoded in nature instead of programmatically handling it.