I am grappling with an array of objects:
let fileArray = [
{ filename: 'File1.txt', bytes: 12345, created: 1548360783511.728 },
{ filename: 'File2.txt', bytes: 34567, created: 1548361491237.182 },
{ filename: 'File3.txt', bytes: 23456, created: 1548361875763.893 },
{ filename: 'File4.txt', bytes: 56789, created: 1548360658932.682 }
];
I have two main objectives for this array: calculating the total bytes of all files in this array sum of numbers and identifying the file created first (smallest) Obtain smallest value from array in Javascript?.
I have considered using array.reduce(), however, it seems to be more suitable for flat arrays. Can it be used on specific keys of an array of objects, or would I need to create a temporary array containing all values for that key in the current array and then use array.reduce() on those values?