executeScript_sandboxed returning error when calling replaceAll string method

Hey. So, I have a workflow that loops through a two-dimensional array created from a csvReadarray step. Within the loop, I have an “execute script sandboxed” step which takes the string stored in one of the columns of the current row and removes all of the spaces from the string with the following javascript:

var aphone=${thing[2]};
return aphone.replaceAll(' ', '');

However, when this code executes, I get this error:

However, when I change the step to just regular Execute Script, the step executes successfully without a problem:

I find this…strange… as I am able to use the “replace” string method successfully within an execute script sandbox step, but not the replaceAll method?

executeScript_sandboxed supports only ES5-level Javascript :nerd_face:

To convert the given ES6 code snippet to ES5, you need to adjust the replaceAll method, which is not available in ES5. Here is the converted version:

var aphone = ${thing[2]};
return aphone.replace(/ /g, '');

In this ES5 version replaceAll method is replaced with the replace method using a regular expression (/ /g) to globally replace all spaces with an empty string