Title Case Function
From Michael Hatch on 12 Feb '02
-
I have a breadcrumbing script that I would like to modify so that
the pieces of the path that are parsed out can be printed on the
screen as title case (Path vs path). I have modified the code to
do it inline, but would like to convert it to a function. The
function should look something like this:
function titleCase(word)
{
var wordLength = word.length;
var newWord = word.substring(0,1).tUpperCase() +
word.substring(1,wordLength);
alert(newWord);
}
The problem comes when I try to use it in a line like this:
function leaveCrumbs()
{
for loop.....
crumb += titleCase(array[i]) + other formating code
end for
document.write(crumb);
}
unfortunately it will alert all day, but I have not been able to
find a way to make it modify the actual variable in the first
function. Any ideas?
TIA
Mike Hatch
|