How could I get a script to remove this empty string from the array?

Flavio Tiezzi
Kilo Sage

Hello everyone,

How could I get a script to remove this empty string from the array?

[
  "test1",
  "test2",
  "test3",
  ""
]

[
  "test1",
  "test2",
  "test3"
]

Thanks in advance.

2 REPLIES 2

emir
ServiceNow Employee
ServiceNow Employee
Look up array.filter

Harish KM
Kilo Patron
Kilo Patron

Hi tested below in background script works fine

var arr = []; 

var array = [
  "test1",
  "test2",
  "test3",
  ""
];
arr = array.filter(function(e){return e});
gs.info(arr);

Regards
Harish