title: How to add an element to an array in karate?
body: <p>How to add an element to an array in karate?
  I have a string array(not json array) from response and add a string element to it for next request.
  I tried a lot with JS functions but with no luck.</p>
  
  <p>Any help is appreciated.</p>
  
  <pre><code>Scenario:123
  
  * def roles = ["role1"]
  * def newrole = "role2"
  * def addrolefn =
  """
  function(role,roles1) {
      var fullrole = [];
      for (var i=0; i&lt;roles1.length;i++) {
  
          fullrole = fullrole.push(role);
      }
      return fullrole;
  }
  
  """
  * def fullroles = call addrolefn (newrole,roles)
  * print fullroles
  </code></pre>