Change resulting json array key to results
Add camelcase output option
Tidy up function
Use native string method endsWith