add silver leading zero

This commit is contained in:
Dušan Juretić 2013-09-23 23:30:13 -03:00
parent c60f6f1c23
commit 939bca1eb9
2 changed files with 3 additions and 2 deletions

View file

@ -269,7 +269,7 @@ module.exports =
###
silver: (num) ->
if num
Math.floor (num - Math.floor(num))*100
("0" + Math.floor (num - Math.floor(num))*100).slice -2
else
return "00"

View file

@ -251,4 +251,5 @@ describe 'Helper', ->
it 'calculates silver coins', ->
expect(helpers.silver(10)).to.eql 0
expect(helpers.silver(1.957)).to.eql 95
expect(helpers.silver()).to.eql 0
expect(helpers.silver(0.01)).to.eql "01"
expect(helpers.silver()).to.eql "00"