I have the existing arrays:
var honda = [ 'civic', 'accord' ];
var toyota = [ 'corolla', 'camry' ];
The user has an option to select vehicle makes:
<select id="vehicles">
<option value="honda">Honda</option>
<option value="toyota">Toyota</option>
</select>
I add an event listener on change to find their selection:
var vehicleSelect = document.getElementById('vehicles');
vehicleSelect.addEventListener('change', chooseMake, false);
var chooseMake = function() {
var selected = vehicleSelect.value;
return selected;
};
My problem: The chooseMake function returns a string. I need a way to pass a reference to either the honda or toyota array into another function, lets say randomizeSelection(chooseMake) that returns a random value from either of the selected arrays.
I already have the randomizer function. I need a way to pass into it, the array that matches the user's selection... instead of the string.