- ( I know you havnt had time to refactor yet and were probably going to do this anyway), but this code is no DRY, you are repeating the same process for each array; 
- Select the array depending on which button the user has clicked and then pass the selected array into the function;