Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- var gold, silver, bronze;
- var total = 0;
- for (var index in args) {
- var tempSplit = args[index].split(' ');
- if (parseFloat(tempSplit[1]) === parseInt(tempSplit[1], 10)
- && parseFloat(tempSplit[1]) >= 0 && tempSplit[0].toLowerCase() === 'coin') {
- total += parseInt(tempSplit[1]);
- }
- }
- gold = Math.floor(total / 100);
- silver = Math.floor((total - (gold * 100)) / 10);
- bronze = total - (gold * 100 + silver * 10);
- }
Advertisement
Add Comment
Please, Sign In to add comment