Let's work on the
smoothScrollTo function. This is the function that detects the scrolling motion to make sure it is smooth. The
smoothScrollTo function is used to move the scroll to the bottom of the page when the page loads. You could use this function in other scenarios to click a button where its click event uses the function to go to a specific section. In our case, we only want to go straight to the bottom. Let's take a look at the function.
Inside its braces, create a callback function. The first line should list the variables
factor, left undefined. Next, create a return function, injecting the variables
duration. Let's take a quick look at what we have so far:
window.smoothScrollTo = (function ...