/Place your JavaScript here to run when the page loads/

Qualtrics.SurveyEngine.addOnload(function()
{

{
	const calcBusinessDays = (startDate, endDate) => {
		var startDate = moment("${q://QID13/ChoiceTextEntryValue/4}","MM/DD/YYYY");
var endDate = moment("${q://QID13/ChoiceTextEntryValue/5}","MM/DD/YYYY");

let BusinessDays = 0;
let totalDays = moment(end).diff(moment(start), "days");
let date = start
for (let i = 1; i <= totalDays; i++) {
if (i == 1) {
date = moment(date)
} else {
date = moment(date).add(1, "d");
}
date = new Date(date);
let dayOfWeek = date.getDay();
let isWeekend = (dayOfWeek === 6) || (dayOfWeek === 0);
if (!isWeekend) {
BusinessDays = BusinessDays + 1;
}
}
Qualtrics.SurveyEngine.setEmbeddedData ( "DaysBetween", BusinessDays);

	}

}
});