So, I am trying to read the array coming from python and python is calling mongodb. As I am trying to read the array, I am getting each character from the array. Like the code is reading the array as a string.
I have tried reading this code in various ways but always getting stuck. First, I am reading the value and putting it in a const variable. Then I am creating a for loop to loop through the array and display each item like '1 - client 1'...
var displayClient = [];
const clients = document.getElementById("clients").value;
var clients_array = clients;
console.log(clients);
var itemDisp = [];
var arrayLength = clients_array.length;
//looping through the objects inside the object
for (var i = 0; i < arrayLength; i++) {
var client = clients_array[i].toString().split(',');
displayClient.push(client[0] + ' - ' + client[1]);
itemDisp.push({ label: displayClient[i]});
}
//calling to diplay in the context menu
return {
"AddClient" : {
label: "Add Client",
"submenu": itemDisp,
disabled: false
}
//the array which I am trying to read
[['1', 'client 1'], ['2', 'client 2']]
the expected result is, to display something like; 1 - client 1... While the actual result is; [ - undefined, [ - undefined, ' - undefined...