By the way Gordo, I suspect you were having problems using it because the variable
d is a number. The function requires a string. When you're having problems like this the easiest way I've found to see what's going on is to use typeof.
try this
Code:
num = '22'
alert(typeof num)
num = 22
alert(typeof num)