I have this code snippet from another question on StackOverflow. Can someone explain to me what is happening here and how it is able to generate times from 12am to 11:30pm and what I should do if I want it only from 9:00 am to 5:30 pm. You don't have to give me the complete code, at least if you guys can help me understand what is happening here, step by step, I'd be able to carry it forward from there. I am pretty new to JS and still learning.
var times = []
, periods = ['AM', 'PM']
, hours = [9, 10, 11, 12, 1, 2, 3, 4, 5]
, prop = null
, hour = null
, min = null;
for (prop in periods) {
for (hour in hours) {
for (min = 0; min < 60; min += 5) {
times.push(('0' + hours[hour]).slice(-2) + ':' + ('0' + min).slice(-2) + " " + periods[prop]);
}
}
}