As I navigate through various arrays to gather data, I encountered a hurdle. My task is to determine the number of days spent in each city. The challenge lies in counting time entries that occur within the same day as just one day. For example, in the given data set, the first two entries for San Diego should be considered one day since they happened on the same day.
timeLogs = [
{'city':'San Diego','date':'2017-03-21T18:52:00.984Z'},
{'city':'San Diego','date':'2017-03-21T12:13:00.984Z'},
{'city':'San Diego','date':'2017-03-19T11:02:00.984Z'},
{'city':'Boulder','date':'2017-02-12T11:29:00.984Z'}
]
The desired output would be:
daysPerCity = [
{'San Diego':'2'},
{'Boulder':'1'}
]
I am currently working on a loop that converts dates to strings and checks for equality. If the dates are the same, I aim not to increment the city count in the new array. However, I'm facing an issue when dealing with the very first instance of a city...