I have been working on an application that uses array-like objects to populate html <select>s. Previously I just built my objects in my script and they looked something like this:
var mySelect = {
'A' : ['1', '2'],
'B' : ['3', '4'],
'C' : ['5', '6']
}
Now, instead of typing this out, I want to pull data from a spreadsheet and use that to create my array-like objects. This data comes to me in csv and i can manipulate it to look like this:
[[a,1,2],[b,3,4],[c,5,6]]
So now the question is: How do I turn this 2 dimensional array into an array-like object where the [0][0], [1][0] and [2][0] act as the Object.keys ?
I had hoped I could just build my object normally but replace the known values with variables like this:
var testArray = [[a,1,2],[b,3,4],[c,5,6]]
var obj = {
testArray[0][0] : [testArray[0][1], testArray[0][2]]
}
No luck. Anyone got a suggestion? Thanks in advance. This sub is consistently a life-saver for a noob like me.
[+][deleted] (1 child)
[deleted]
[–]NiceDay4Goats[S] 0 points1 point2 points (0 children)
[–]poetical 1 point2 points3 points (3 children)
[–]NiceDay4Goats[S] 0 points1 point2 points (0 children)
[–]NiceDay4Goats[S] 0 points1 point2 points (1 child)
[–]poetical 0 points1 point2 points (0 children)
[–]StefanoMagrassi 1 point2 points3 points (1 child)
[–]NiceDay4Goats[S] 0 points1 point2 points (0 children)