I have an array of items, and I am trying to assign a variable name based on each of the array's item names. For example, if the array has the values:
var thearray = {};
thearray['0'] = 'car';
thearray['1'] = 'boat';
thearray['2'] = 'truck';
I want to end up with three variables, named car_output, boat_output, truck_output.
They will all contain the same data. Here is how I'm trying to do it:
$.each(thearray, function(index, value) {
var value+'_output' = 'stuff...'; // something not right
});
Something is not right with the way I'm trying to name each variable. Any ideas?
+sign and a constant'_output'? The LHS should be a variable only$('#'+value).html(value+'_output');. It's just showing the actual word, for example "car_output" and not what the var "car_output" actually is.