@TomasPereira-Dev
Posted
Hey!, what's up?.
Glad to hear that you were brave enough to try to solve the bonus animation! it's quite tricky.
What you need to do is use the setInterval function, that every x miliseconds adds +1 to a state variable, if the state variable is bigger than the variable that you used to save the calculated date, the function should stop.
I did it this way in vanilla JS:
let dayNumber = 0; //this should be a state.
let calculatedDays = 420 //this should be what you used for saving the aready calculated days
const daysIntervalAnimation = setInterval((days) => {
daysNumberParagraph.innerHTML = `<p>${dayNumber} <span>days</span></p>`;
dayNumber += 1;
if (dayNumber > days) clearInterval(daysIntervalAnimation);
}, 30, calculatedDays);
here's some info about how the setInterval method works
You can also check my code out if you want a more detail version .
Good luck!.