0

I could use some help adding empty strings in an array returned by Zapier for emails that has blanks indicated by commas. It looks like this:

input email jbrooks_ca@yahoo.com,,,,jkburtie@gmail.com,skyelea@hotmail.com,etc...

What I'd like it to look like is: jbrooks_ca@yahoo.com,'','','',jkburtie@gmail.com,skyelea@hotmail.com,

If anyone is familiar with writing JS for Zapier I would love some insight as I'm not very strong at writing JS.

Here are the two screens in Zapier handling the code output as reference.

the initial content pulled by Zapier

the output content once the JS has rendered

4

1 回答 1

2

在 Zapier 代码框中试试这个:

var emails = input.email.split(',');
var new_emails_str = "";
for (var i in emails) {
    var e = emails[i];
    if (e) {
        new_emails_str += e + ",";
    } else {
        new_emails_str += "'',"; 
    }
}
output = [{emails: new_emails_str}];

截屏:

在此处输入图像描述

我在测试时看到的结果:

在此处输入图像描述

于 2016-07-27T19:50:20.297 回答