Compressed if else section, removing a lot of

repetitive code and instead looping through to keep adding relevant
values from the array to the masterString. Bonus that should allow
length of array to vary.