Skip to content
Advertisement

How to explode a string and calculate a sum?

I want $total to be output as just a sum of a number but everytime i sum up $total it outputs multiple numbers

JavaScript

expected output:

JavaScript

Advertisement

Answer

There were a few syntax errors in your codes. Other than that, your calculation looks fine, and great job with explode();.

Code:

JavaScript

Output:

You might check out to see if the math is right.

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