I'm trying to figure out how to subtract two different dates to get the remainder. Based on my Google searches, this seems like it should be pretty straight forward, but my code just isn't working as expected.
const options = { year: 'numeric', month: 'numeric', day: 'numeric' };
let today = new Date();
today = today.toLocaleDateString('en-US', options); // '2/20/2019'
dueDate = new Date(dueDate[0]);
dueDate = dueDate.toLocaleDateString('en-US', options); // '12/15/2019'
daysLeft = today.setDate(today.setDate() - dueDate); // Being declared as a let outside the scope block
The error message I'm receiving is: Uncaught (in promise) TypeError: today.setDate is not a function
UPDATE:
The possible duplicate answer almost helped me, but it doesn't account for the years so 2/20/2019 - 2/1/2001
is outputting 19
, which is incorrect.