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">
    <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=""></script>
    <title>Static Template</title>
    <button onclick="changeval()">Done</button>
    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);

You can access the code here: