Javascript error on .split.filter

e_wilber
Tera Guru

I am trying to run this snippet of code in a background script to prove it works on my data but it errors out with 

Javascript compiler exception: syntax error (null.null.script; line 😎 

 

This is the line in question: 

 const entries = logString.split(pattern).filter(logStr => logStr.trim() !== '');
 
This snippet was built using real documentation so I figure it should work (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter). Any idea what I might need to do to make this work in SN?
1 REPLY 1

Jon23
Mega Sage

Hi @e_wilber ,

Take a look at this community post that talks about using Array Filtering (and other Array methods):

Fun with array methods!