metamerist

Saturday, March 04, 2006

A Small Gift to Humanity

Over the years, I've been scolded countless times by web pages for including or not including dashes in phone numbers and credit card numbers. These frustrations prompted me to descend to my basement laboratory to search for an answer.

After months intense of cogitation and wiping the beaded sweat from my brow, I discovered a means of removing dashes from JavaScript strings. Even though this is a technical achievement so stupendous it dwarfs One Click Shopping, I shall relinquish all patent rights and humbly offer it freely in the name of social progress:

function removeDashes(s)
{
var t = '';
for(var i=0; i {insert less than sign here} s.length; i++)
if (s.charAt(i)!='-')
t = t + s.charAt(i);
return t;
}


Update: Argh! I can't figure out how to get a less than sign to work in Blogger. The HTML conversion blows it.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home