Function for formatting an array This function is working fine but I'm looking for any better alternative:

function formate(array) {
    var formattedArray = [];
    var count = array.length;

    for (var i = 0; i &lt; count; i++) {
        formattedArray.push({
            all: array[i].all ? array[i].all.split(',') : [],
            any: array[i].any ? array[i].any.split(',') : [],
            not: array[i].not ? array[i].not.split(',') : [],
        });
    }

    return formattedArray;  
}


Input:

[{all: "one,two", any: "three,four", not: ""},{all: "five,six", any: "", not: "seven"}]


Output:

[{all: ["one", "two"], any: ["three", "four"], not: []}, {all: ["five", "six"], any: [], not: ["seven"]}]
const formate = array =&gt; array.map(({all, any, not}) =&gt; ({all: all.split(","), any: any.split(","), not: not.split(",")}));


With empty arrays:

const formate = array =&gt; array.map(({all, any, not}) =&gt; ({all: all?all.split(","):[], any: any?any.split(","):[], not: not?not.split(","):[]}));