Here's the simple situation: I'm currently developing an internal calculator for my team to determine the pricing of the t-shirts we offer.
https://i.sstatic.net/k9J2n.png
We have a similar pricing grid as shown in the image provided. The form has fields for entering quantity and number of colors for screen printing. How can I efficiently store this information for calculations without resorting to a messy nested if-else structure?
I've experimented with using arrays, but I am uncertain about the most effective way to organize the data.
if (parseInt(this.qty, 10) < 36) return
if (parseInt(this.qty, 10) <= 72) return 0.85
if (parseInt(this.qty, 10) <= 144) return 0.75
if (parseInt(this.qty, 10) <= 288) return 0.65
This current method is far from optimal, although it functions to some extent. I am seeking a cleaner solution that incorporates the number of colors into the calculation without relying on numerous if statements.
What would be the best approach to tackle this issue? I don't necessarily require specific code, just a theoretical concept. This project serves as a learning opportunity for me, so I aspire to handle it independently, but I could use guidance on where to start.