0

I have a function that stores files data in an object. The files get saved in the object with their original names, I want to rename the files names with custom names.

That's what I did, it works fine, I'm just wondering if there is a way to do it without the mediation of a new variable(newObj).

const {
    'test123': purchase, 
    'test456': purchase2, 
    ...rest
} = stories
 newObj = {purchase, ...rest}
 console.log(newObj)

Stories object:

stories {
    'test123': StoryProvider {
              info: StoryInfo {
                client: [Object],
                company: [Object],
              },
              costs: StoryCosts {
                test: test,
              }
    },
    'test456': StoryProvider {
              info: StoryInfo {
                client: [Object],
                company: [Object],
              },
              costs: StoryCosts {
                test: test,
              }
     }
}
user3378165
  • 6,546
  • 17
  • 62
  • 101

0 Answers0