Count not saving the updated value

i wanted to save the count and print it outside the setinterval however in my setInterval i already add this "count += 1;" but when i print the count outside the setinterval , it still printing the default value.. im not sure what i did wrong. Kindly help . Thank you

This is the code:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <title>Static Template</title>
  </head>
  <body>
    <button onclick="changeval()">Done</button>
  </body>
  <script>
    function changeval() {
      var count = 0;
      setInterval(function () {
        for (var i = 0; i < 10; i++) {
          // do something
        }
        count += 1;
        console.log("count", count);
      }, 600);

      console.log("count outside", count);
    }
  </script>
</html>

You can access the code here: https://codesandbox.io/s/blissful-tdd-gm4mn?file=/index.html:0-721