function unique()
{
// Step 1: total ASCII characters=256, so take array of size 256, from 0-255, first time fill all positions with '0'
a = new Array(255);
count=0;
k=0;
str = document.formname.fieldname.value; // string to check.
for(i=0 ; i<255 ; i++)
{
a[i]=0;
}
// Step 2: whenever any character comes, i am incrementing its ASCII position.
for(i=0 ; i<str.length ; i++)
{
k=String.charCodeAt(str[i]);
a[k]++;
}
// Step 3: Checking which position is equal to '1' and then fetch corresponding ASCII character.
for(i=0 ; i<255 ; i++)
{
if(a[i] == 1)
{
document.write(String.fromCharCode(i)+" ");
count++;
}
}
document.write("<br />Total Number Of Unique Letters In A String = "+count);
}
Jun 7, 2010