Output the Scroll Position on Console

Firstly you never call the example() function so it will never execute. You need to call the example() function under the scroll event of the element required. Secondly you need to update the value of the tempScrollTop variable inside the function. Try this:

$(window).scroll(example);

function example() {
  var tempScrollTop = $(window).scrollTop();
  console.log("Scroll from Top: " + tempScrollTop.toString());
};
html, body {
  height: 2000px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>