Orbital period challenge help

How can I copy the argument(arr) which is an object into a new variable

function orbitalPeriod(arr) {
  let newArr = object.assign({},  arr);
  return newArr;
orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}]);

arr is not an object. It is an array containing one or more objects.


I assume, the first letter of “object” has to be uppercase (capital) => Object . But you use it here in lowercase.

Thanks I figured it out at some point

obj return undefined from this piece of code. what I’m trying to do here is change the key name (avgAlt) to orbitalperiod.

function orbitalPeriod(arr) {
  let newArr = [...arr];
  let realArr = newArr.map(obj => {
      newArr["avgAlt"] = newArr["orbitalPeriod"]
      delete newArr['avgAlt']; 
      return obj; 

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

the function orbitalPeriod doesn’t have a return statement so it returns undefined by default

the return statement you see is for the callback of the map method

So how can I change the object key here

what does the map method do? why do you think it is a good fit here?

could you also please post the challenge link?

I think the map method should check for every key (avgAlt) and change it to orbitalperiod.

the map method returns a new array where each element is changed based on the callback

how to use map method: the callback should not change stuff outside of itself, it should not have side effects, the callback parameter is the element of the array, and the callback should return the new element in the new array
you are not using the parameter inside your function, also you are giving a property to an array, you shouldn’t do that. remember that the elements of the array are objects