I am facing an issue with storing values within a JavaScript object notation based on the field selected by the user. While I can store the value in a string separated by commas, when the element I'm trying to access is an array, I receive [object object] as a return since it's an array. I am seeking a solution to store all items in that array into a variable separated by commas. For instance, if "Time" is selected, I want it to display "Dec 9, 1, 2012."
In the given example, there is a function called findProps. When I provide the argument entityCount inside findProps("entityCount", data), I get a proper return type of 50 as per the JSON provided. However, when I add findProps("Time", data);, it returns [object, object] instead of the actual values inside those arrays. I aim to have all values inside the array displayed (like Dec 9, 1, 2012) regardless of different keys and depths of the array. This is just a static example being used.
I have achieved fetching the value for non-array elements but having trouble extracting the values from arrays dynamically depending on their depth. Here is a link to the current progress: http://jsbin.com/obehog/3/edit
I also attempted another approach which almost worked, but my lack of expertise in recursion has me stuck. You can view this attempt here: http://jsbin.com/obehog/4/edit. The varying depths of arrays in each scenario make using loops ineffective.