Skip to content

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 …

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