Recently I've jumped into JavaScript programming and yesterday I was watching [this](https://youtu.be/HE6KfMSTHKE) video about mutability and I got totally confused about the program the host wrote.
Here it is:

```js
let newObj = 
{
    total: 65,
    increment: 1
};

const IncrementTotal = function(obj, val)
{
    obj.increment = val;
    return function()
    {
        console.log(obj.total);
        obj.total = obj.total + obj.increment;
        console.log(obj.total);
    };
};

const incBy1 = IncrementTotal(newObj, 1);
const incBy2 = IncrementTotal(newObj, 2);
```

```html
<!DOCTYPE html>
<head>
    <title>JS Test</title>
</head>
<body>
    <script src="test1.js"></script>
</body>
</html>
```

I've also added the HTML code from my side.

When the page is loaded and we call `incBy1()` in the browser console, the result is

`65`

`67`

At this point I'm unable to follow the host. He says something like 

*by the time* `incBy1()` *executes, the value of* `increment` *is* `2` *and both of them point to the same object*

---

What I'm unable to grasp is why is `incBy2()` called in the first place (we didn't call it)? Is it because it's below `incBy1()`? But then why isn't the data being logged into the console four times (*two times for each*)?

I want to understand how does the program actually execute and why is the output like this.