Skip to content
Advertisement

Calculate total price on different percentage for each increment

I am trying to write a calculator for price estimation

so that :

for 1000 MTU price will be 0.035 so total will become 35 for 2000 MTU price will be 0.034 total will become 67 for 3000 MTU price will be .0329 total will become 98.79

and so on….

I write the following code but its giving NaN error.

Any new suggestion to write a efficient code will be appreciated.

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Use parseInt() to convert input value from string to integer, so you can calculate your prices. Other than that You are using a function calculateCost() inside your event listener, I correct this in the code, so this is the result:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement