i want to make an React native app that help train driver calculate how they shoul use parking break. I have this big table where you have to variable (how much the train wight on column and the angle on row, where the train has to be parked). So the user input the values and the right amount of forced from table should be shown. If i would do that with if statements this will take too long and may case problems.Same with case statements. Any ideas how could i do that with JavaScript?
I triend with Database and it will require even more code than 'if' statemens, sience those are not the only variables. So i have no other ideas how should i do that. This is the table, i have two of these
You need to first build an Object to hold the table data, like this:
let data = {
"2.5%<24h": {
"40t": 1,
"80t": 2,
"100t": 3
// etc.
},
"2.5%>24h": {
"40t": 2,
"80t": 4,
"100t": 5
// etc.
},
"3%": {
"40t": 3,
"80t": 5,
"100t": 6
// etc.
}
// etc.
};
You can store it in a separate file from the rest of your code and import it into your code.
When you want to access this data you go to the appropriate column and row, like this:
data["3%"]["80t"]
This will give you 5.