String toLowercase?

Is it possible to convert an array to lowercase using toLowercase()? I have an array that consists of a list of usernames that I need to make all lowercase. I tried using storeEval | storedVars[‘usernames’].toLowerCase(); and variations thereof, but no luck so far.

All things in target of storeEval happen in the guest page context, variables in Kantu won’t be affected.

The solution is the same as for changing values inside an array. Assign the values to a javascript array, use standard JS to replace the values, and then assign the updated array back to the Kantu variable.

There are few methods to convert all items in an array to lower or uppercase. A useful array method is map. It basically loops through all elements of an array, applies a function to them and pushes the results into a new array:

arr = storedVars['names'], newArray = arr.map(function(x){ return x.toLowerCase()}) , newArray

My test macro converts 'cAT','Dog','FISH' to 'cat','dog','fish':

Screenshot:

{
  "Name": "array_to_lowercase",
  "CreationDate": "2019-1-9",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://a9t9.com/kantu/demo/storeeval",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "new Array ('cAT','Dog','FISH')",
      "Value": "names"
    },
    {
      "Command": "comment",
      "Target": "convert all values in NAMES to lower case",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "arr = storedVars['names'], newArray = arr.map(function(x){ return x.toLowerCase()}) , newArray",
      "Value": "names"
    },
    {
      "Command": "storeEval",
      "Target": "storedVars['names'][2] ",
      "Value": "a2"
    },
    {
      "Command": "echo",
      "Target": "The 2nd element of the array is ${a2}",
      "Value": "blue"
    }
  ]
}