JavaScript DataTables rows.add(array).draw() is getting called multiple times datatable rows add array

I have done this to create number of columns based on the data my server returns back. I want to check if the data in the array matches the column name, if it does then return yes else return no.

function initTable(userJvmsArray) {
            var collumnsCallbacks = [{
                title: "Username",
                data: "username"
            }];

            for (var i = 0; i < $scope.unique.length; i++) {
                $('#nameColumn').after('<th>' + $scope.unique[i] + '</th>');
                var jvm = $scope.unique[i];
                var col = {
                    title: jvm,
                    data: function(data, type, row) {
                        var data2 = data;
                        var jvms = $scope.unique;
                        for (var k = 1; k < jvms.length; k++) {
                            console.log(jvms);
                            for (var j = 0; j < data2.myarray.length; j++) {
                                if (table.column(k).title() == data2.myarray[j].Name) {
                                    console.log(table.column(k).title() + " = " + data2.myarray[j].Name + " YES");
                                    return "yes";
                                } else {
                                console.log(table.column(k).title() + " = " + data2.myarray[j].Name + " NO");
                                    return "no";
                                }
                            }
                        }


                    }
                };
                collumnsCallbacks.push(col);
                $scope.columns = collumnsCallbacks;
            }
            $scope.myTable = $('#myTable').DataTable({
                'paging': true,
                "pageLength": 3,
                'columns': collumnsCallbacks
            });

Problem is that the function seems to run more than once and populating the table incorrectly, this is my console log:

["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66

["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO myctrl.controller.js:69
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO myctrl.controller.js:69

["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO myctrl.controller.js:69

["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO myctrl.controller.js:69
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user1: myword = myword YES myctrl.controller.js:66
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO myctrl.controller.js:69
["myword", "secondword", fastLoop: function, fastLoopAsc: function] myctrl.controller.js:63
user11: myword = secondword NO 
Answer:1

I am struggling with an excercise question and maybe you could help me. I have to set up a camera and cube with THREE.js. The cube should keep its initial ratio and the camera should look at the ...

I am struggling with an excercise question and maybe you could help me. I have to set up a camera and cube with THREE.js. The cube should keep its initial ratio and the camera should look at the ...

For the CMS page editor in Magento,i would like to change the formatting of the H tags in the tinyMce editor. I would like something like for H1 tag, it is in red, bold, font:36px. how would i go ...

For the CMS page editor in Magento,i would like to change the formatting of the H tags in the tinyMce editor. I would like something like for H1 tag, it is in red, bold, font:36px. how would i go ...

Does anyone know why the height could be zero here? $(document).ready(function () { alert($("#hello").height()); }); <script src="https://ajax.googleapis.com/ajax/...

Does anyone know why the height could be zero here? $(document).ready(function () { alert($("#hello").height()); }); <script src="https://ajax.googleapis.com/ajax/...

  1. jquery element height returns 0
  2. element height returns 0
  3. jquery height returns 0
  4. jquery div height returns 0

I'm thinking using S3 Amazon for storage (if you guys have better one, don't hesitate to recommend). I could do a normal file upload, but let's say I'm uploading a very large video/music file (...

I'm thinking using S3 Amazon for storage (if you guys have better one, don't hesitate to recommend). I could do a normal file upload, but let's say I'm uploading a very large video/music file (...

  1. google cloud storage multipart upload