I have been assigned to display to the user the number of days since their last visit to my website and have to use the "localStorage" web api. I believe I have a good start, and I know that I will need to access and store the last visit date and get the difference between the current date of their visit. I am just unsure of how to access the date of their last visit.
Here is my code:
HTML:
<article>Days since your last visit:<span class="timeBetween"></span></article>
The class name of the span I want to display to is "timeBetween"
JavaScript:
const visitsDisplay = document.querySelector('.timeBetween');
let numVisits = Number(window.localStorage.getItem("timeBetween"));
//This is where I believe I need to get the days between visits
//Something like:
const visitDifference = "pastvisit" - Date.now();
localStorage.setItem("timeBetween", visitDifference);