Jun 16, 2017 ยท Adding strings to an array in Ansible. From time to time, I need to dynamically build a list of strings (or a list of other things) using Ansible's set_fact module. Since set_fact is a module like any other, you can use a with_items loop to loop over an existing list, and pull out a value from that list to add to another list.. 3 Ways Adding Items to the End of a JavaScript Array. JavaScript comes with the Array#push method allowing you to push one or more items to the end of the array. You may also append new items by creating a new array using the spread operator to push existing items to the beginning. You can use a loop (for or foreach) to add items to controls. In my example code I use switch statement to populate dropDownList respectively. "/>Add item to string array