I want to create an array from user input. I dont know the details of input, so basically I just need to define, initialize and populate the array with input data, so that I can do further actions later.
example array could look something like this:
var input = ["1" : ["0": "Apple",
"1": "Orange"],
"2" : ["0", "Cat",
"1", "Dog"],
"4" : ["0", "Coffee"]
];
Now, I dont know how to define, initialize and populate it, as this is not working:
var input = [[]];
$('.input').each(function(index, element) {
var element_id = this.id;
var element_value = $.trim(this.value);
input[element_id][index] = element_value;
});
Any javascript experts who could help?