I have to clean up some Javascript and I am trying to figure out a more elegant way to write this code below. It's basically looping through 3 dictionaries with the same loop structure and appending some custom HTML onto a specific div.  I wanted to see if there is a way to avoid this repetitive code:if (dtInt in calendarEventDict) {    var arrEvents = calendarEventDict[dtInt];    for (var a = 0; a < arrEvents.length; a++) {        var calendarEvent = arrEvents[a];        $(#dateCupcake + i).append(<div  dateId=' + calendarEvent.Date + ' class='event  + cal + calendarEvent.CalendarId +   + calendarEvent.CalendarClassName + ' calendarId=' + calendarEvent.CalendarId + ' eventDateId=' + calendarEvent.Id + ' id=' + calendarEvent.EventId + '> + calendarEvent.DisplayName + </div>);    }}if (dtInt in vacationEvents) {    var arrEventsV = vacationEvents[dtInt];    for (var v = 0; v < arrEventsV.length; v++) {        var vacationEvent = arrEventsV[v];        $(#dateCupcake + i).append(<div  dateId=' + vacationEvent.Date + ' class='event  + cal1 blueAllDay' calendarId='1' eventDateId=' + vacationEvent.Id + ' id=' + vacationEvent.EventId + '><img src='/Content/Images/Icons/pawn_glass_ + vacationEvent.ApprovalIcon + .png' /> + vacationEvent.PersonName + </div>);    }}if (dtInt in travelEvents) {    var arrEventsV1 = travelEvents[dtInt];    for (var v1 = 0; v1 < arrEventsV1.length; v1++) {        var travelEvent = arrEventsV1[v1];        $(#dateCupcake + i).append(<div  calendarId='2' dateId=' + travelEvent.Date.ToString(MMM dd, yyyy) + ' class='event  + cal2 +  blueAllDay' calendarId='2' eventDateId=' + travelEvent.Id + ' eventId=' + travelEvent.TravelRequest.Id + '><img src='/Content/Images/Icons/user1_earth16.png' /> + travelEvent.TravelRequest.Person.LastName + ,  + travelEvent.TravelRequest.Person.FirstName.Substring(0, 1) +  visiting  + travelEvent.TravelRequest.TechnicalCentre.Name + </div> );    }}
Rendering three types of events as HTML elements
javascript;jquery;dom