How do i split a string so its becomes [0] [1] on runtime in loop
var str = 'Hello, World, etc';
var myarray = str.split(',');
for(var i = 0; i < myarray.length; i++)
{
alert(myarray[i]);
}
How do i do like this but with my code so the first time the loop runs take both values and not first value and then second time take second value , both values on same time?
EventDate and EndDate are two columns from my List there i have values in.
function onQuerySucceeded() {
var startCon = listItemCustom + "T" + "08" + ":00" + "Z";
var endCon = listItemtoDate + "T" + "17" + ":00" + "Z";
var dtstartCon = new Date(startCon);
var dtEndCon = new Date(endCon);
var convertUtctoFromtime = new Date(dtstartCon.getTime() + dtstartCon.getTimezoneOffset() * 60 * 1000);
var start = new Date(convertUtctoFromtime);
var convertUtcToTime = new Date(dtEndCon.getTime() + dtEndCon.getTimezoneOffset() * 60 * 1000);
var end = new Date(convertUtcToTime);
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
var listEventDate = oListItem.get_item('EventDate');
var listEventdt = new Date(listEventDate);
var listEndDate = oListItem.get_item('EndDate');
var listEventEnddt = new Date(listEndDate);
var string = listEventdt + "," + listEventEnddt;
var res = string.split(",");
while (end.getTime() >= start.getTime()) {
var firstnewDate = (start.setTime(start.getTime()));
var firstNewDt = new Date(firstnewDate);
var newDate = start.setTime(start.getTime() + 30 * 60 * 1000);
start = new Date(newDate);
for (var i = 0; i < res.length; i++) {
var date = res[i];
var dt = new Date(date);
var date2 = res[i];
var dt2 = new Date(date2);
if (firstNewDt.getTime() != dt.getTime() && start.getTime() != dt2.getTime()) {
alert(firstNewDt + " " + start);
} else {
alert("Busy");
}
}
}
}
}
when running the for loop first time it will put the same value in dt.getTime() as with dt2.getTime() i want to take the value from EventDate and EndDate on same time when the loop runs, and not first take value from EvenDate and put them in both start and end time, and second time the loop runs it will put the endDate in dt.geTime() and dt2.getTime(), but i want to have it like when the loops runs take the value from the split [0] and [1] and put value from [0] in dt.getTime() and [1] in dt2.geTime() right now it takes [0] on both-