I'm very curious as to why my code won't run properly. I retrieve the value for the Date input from the html file and I created a function to find the difference; however, the span element will not update. Please explain to me why I'm wrong and what I could do to fix it. Thanks!
const setup = () => {
let firstDate = $('#firstDate').val();
let secondDate = $('#secondDate').val();
const findTheDifferenceBetweenTwoDates = (firstDate, secondDate) => {
let timeDifference = Math.abs(secondDate.getTime() -
firstDate.getTime());
let millisecondsInADay = (1000 * 3600 * 24);
let differenceOfDays = Math.ceil(timeDifference / secondsInADay);
return differenceOfDays;
}
let result = findTheDifferenceBetweenTwoDates(firstDate, secondDate);
$("span").text(result);
}