I have tried my best the whole day but I can't find a working solution for my problem.
Here is it.
I have an object containing the list of folders and the number of files inside each one like this:
let Folders = {
'listen': 0,
'listen_again_long': 0,
'intercations': 0,
'watch_again': 0,
};
And an array named result
that contains the list of files inside the parent folder of above object.
let result = [
"https://example.com/test/media/instructions/listen/1.mp3",
"https://example.com/test/media/instructions/listen/2.mp3",
"https://example.com/test/media/instructions/listen_again_long/1.mp3",
"https://example.com/test/media/instructions/listen_again_long/2.mp3",
"https://example.com/test/media/instructions/listen_again_long/3.mp3",
"https://example.com/test/media/instructions/listen_again_long/4.mp3",
"https://example.com/test/media/instructions/watch_again/1.mp3",
]
I want to count the files inside each folder (listen...listen_again_long...)
based on information represented in result
array and modify the numbers of Folders object...
For instance in the above sample codes we have 2 files inside listen and 4 inside listen_again_long and 1 inside watch_again and none in intercations. so we should get back the object like this:
let Folders = {
'listen': 2,
'listen_again_long': 4,
'intercations': 0,
'watch_again': 1,
};