Skip to content
Advertisement

Tag: multidimensional-array

Convert 2D JS array to json string

My array in variable is: I’ve mentioned key and value here for the 2D array, I’m trying to convert this to JSON string. I tried JSON.stringify(arraydata), arraydata is the variable where the array is stored, but it makes the string empty, whereas array data is correct. Edit: This is how I’m adding array data: Answer The “array” quoted in your

Pass multi-dimension array into Google.visualization.arrayToDataTable

I want to draw a candlestick chart by using Google Chart , i have a multi-array array call chartdata and i failed to pass the multi-array array into google.visualization.arrayToDataTable([chartdata],true) and give errorLast domain does not have enough data columns (missing 3) it should look like this var data = google.visualization.arrayToDataTable([ [‘2022-05-25 12:00’,12,864,889,76], [‘2022-05-25 13:00’,765,45,97,82] ],true); html js Answer In your

How to combine 2 arrays in a way that 1st element of array1 and 1st element of array2 and so on form a new array

I have 2 arrays. The first contains the years like [2021,2020,2019,2018,2017] and the second contains number of occurrence like [2,3,1,3,3] I want the new array to look like this [[2021,2],[2020,3],[2019,1],[2018,3],[2017,3]] How to do this? Please help! Thank you in advance. UPDATE: I tried doing this and it works fine but the new array looks like this How to make it

Get a value from a multidimensional array

I have a multidimensional array as follows: In my form the user would input a weight. What I am trying to do is if the weight is equal to or below the number in the weight part of the array that the corresponding rate is assigned to a variable. Am stuck on how to do this. Any push in the

Advertisement