I have an object and depending of the number of properties in that, I need to create a new array.
const data = {
name: 'John Doe',
company:'Google'
}
So, the new array should be like this:
const array = [
0: {
id: 3434,
fileId: name, //from data
criter: 'John Doe;
address: '12345'
}
1: {
id: 4233,
fileId: company, //from data
criter: 'Google;
address: '32344'
}
]
I have tried to create array and to use Object.keys and Object.values to get the data, but I'm not achieving this.
const testArray = [{
criter: Object.values(data).map(key => key),
fileId: Object.keys(data).map(key => key)',
}];
Object.entries()will helpdataI'm trying to create new array with new objects. (in this case two objects)