I am making a special "calculator" which accepts user input and looks up data in a table to find a result. But I'm having trouble with how best to do this, to avoid tons and tons of if statements.
As an example, say there are some sets of radio buttons, and each combination of buttons has a unique value which I want to show the user. What sort of data structure would I use in JavaScript to account for each combination of buttons and look up the corresponding value?
Edit: upon request, here is some example data:
| Type | Color | Output value |
| small | red | 21.9 |
| small | blue | 27.3 |
| small | yellow | 26.8 |
| large | red | 19.2 |
...
The user is then presented with two radio sets or dropdowns, one for type and one for color. Upon choosing the combination and pressing the button, the output value is shown.
In my specific case I have a table with 4 different columns and many combinations. It looks like an array will do, but if it's an array of objects then I have to type the column names on every row (i.e.: {type: 'small', color: 'red', output: 21.9}, ...) -- is there a way to keep the associative nature of objects with the compact array syntax such as ['small','red',21.9] ?