I have developed a unique coin box that recognizes the value of each coin inserted. Users can now pay for a service that costs 2.0 € by inserting coins of various denominations such as 2.0 €, 1.0 €, 0.50 €, 0.20 €, and 0.10 €.
In my react-native project, I implemented a function that stops the coin box (listener) once the total reaches 2 euros.
However, I am facing a challenge of how to correctly sum up the total value when users insert different coins with varying denominations.
Below is the code snippet:
// Code snippet will be here
Your assistance in solving this issue would be greatly appreciated. Thank you!