0

I'm using SSJS to pull api data and build emails. I have an array built that has some duplicate data in it. I'm looking for anyway to remove the duplicate information. I've tried all the regular JS methods, filter, spread operator, etc... but not seem to the trick. Does anyone have any experience with or any ideas?

var uniqe_mls_array = [...Set new(mls_text_array)]; // Didn't work, can't use new

Any help would be greatly appreciated, thank you.

1 Answer 1

0

The following seems to work but may be overkill:

    var outputArray = [];
    var count = 0;
    var start = false;

for (j = 0; j < mls_text_array.length; j++) {
    for (k = 0; k < outputArray.length; k++) {
        if (mls_text_array[j] == outputArray[k]) {
            start = true;
        }
    }
    count++;
    if (count == 1 && start == false) {
        outputArray.push(mls_text_array[j]);
    }
    start = false;
    count = 0;
}

Variable.SetValue("@mls_text_string", outputArray.toString());

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .