I have an array of 5 strings and I want to be able to compare the strings to each other to find out if there is a majority, and return that majority. So if:
a[0] = "dog";
a[1] = "dog";
a[2] = "dog";
a[3] = "dog";
a[4] = "cat";
I want to return "dog." In cases like 2 same, 2 same, and one, I want it to return "no majority". Is there a way to do this without a tremendous amount of if statements, in other words elegantly?