I've populated an array with a random number of strings.
var array = ["car", "plane", "plane", "car", "car"];
I want to access the values in the Array and count how many times each one has been added. For example:
var a = "car";
var aCount = 3;
var b = "plane";
var bCount = 2;
var text = "'" + a + "'" + " was found " + aCount + " times";
return text
I'm not sure how to use a loop to compare array[i] with all other values in the array, especially since the length of the array is random?
Thank you.