Simple logic in javascript
- by Saurabh
I have four variables of type integer -
var tip_1, tip_2, tip_3, tip_4;
The value of these variables are getting fill by some other logic which is always between 1 to 10. I need to maintain a hash with variable name as "key" and value as "value" by following these rules -
The variable with MAX value should be the first element in the hash and so on. e.g.
if tip_1 = 4, tip_2 = 1, tip_3 = 2, tip_4 = 10 then hash should be something like,
Hash = {tip_4, 10} {tip_1, 4} {tip_3, 2} {tip_1, 1}
In case of tie following order should be considered -
tip_1 tip_2 tip_3 tip_4;