tipCalculator = (function() {
function roundToHundreths(num) {
return Math.round(100*num) / 100
}
function findPercentage(percent, amount) {
return roundToHundreths(amount * percent);
}
return {
fifteen: function(amount) {
return "$" + findPercentage(0.15, amount)
},
twenty: function(amount) {
return "$" + findPercentage(0.2, amount)
},
twentyFive: function(amount) {
return "$" + findPercentage(0.25, amount)
},
thirty: function(amount) {
return "$" + findPercentage(0.3, amount)
}
}
})()