I am fairly new to javascript. I am stuck on this code.
I'm trying to create a button to navigate between top and bottom of a web page. Initially, the *scroll to bottom* works, but once I click on the *back to top* button, the scroll down logic breaks. I'm unable to figure out where I'm applying the incorrect logic. Thanks in advance

<https://jsfiddle.net/riodahamster/9vtxh0aL/9/>

```
var i = 1;
$(".scroll-top").click(function() {
  $("html, body").animate({
    scrollTop: 0
  }, "slow");
  window.icount = 0;
});

var icount = 0
$('.down-btn').on('click', function(e) {
  e.preventDefault();
  window.icount++;
  var offset = $("div.next-section").eq(icount).offset().top;
  $('html, body').stop().animate({
    scrollTop: offset
  }, 400);

});

```