Why this piece of code is not working on Internet Explorer? [duplicate]

Math.trunc is not supported in IE as MDN states, please read here.

Instead you could use polifylls:

if (!Math.trunc) {
    Math.trunc = function (v) {
        return v < 0 ? Math.ceil(v) : Math.floor(v);
    };
}

Hope that clarifies.