Trouble using MathJS API

Hello all :slight_smile:
I am a beginner and I have an issue.
I created a simulation to calculate how much someone can save if they had an electric. When the slider moves the number of kilometers changes and I have formulas to calculate how much it costs for gasoline and electric. But I have two issues.
1 - I can’t see how I can sum the two numbers I found to have a total

2 - I want to have a different formula depending whether it’s a diesel or gasoline car. What would the most effective way to have different formulas depending on conditions a user would check before?

Thanks a lot for you help :slight_smile: