I have a mapping in my contract like below:
mapping (address => uint) public voterCount;
To calculate the total votes, I would like to loop through the mapping and sum the uint values. How do I do this in solidity? One solution is to use another variable say
totalVotes that is incremented every time
voterCount is updated. I am trying to see if there is a cleaner solution where I don't need an additional variable to keep track of the count.