Forum : to find a number of unique letters in string
Brief description  about Online courses   join in Online courses
View RAM MOHAN RAO 's Profile

to find a number of unique letters in string

<html>
<head>
<script type="Text/javascript">
function code(n, digits, padChar) {
n = n.toString();
while (n.length < digits) {
n = padChar n;
}
return n;
}
var str = window.prompt("Enter String");
var array = [];
var totalCount;
var count=0;

for(var i = 0; i < str.length; i ){
if(!array[str[i]]) {
array[str[i]] = 1;
} else {
array[str[i]] = 1;
}
}
sortedArray = [];
for(var i in array){
sortedArray.push(code(i.charCodeAt(0), 5, '0'));
}
sortedArray.sort();
for(i = 0; i < sortedArray.length; i ){
count ;
}
document.write("Number of unique letters are: " count);
</script>
</head>
</html>

please know what is wrong with this code?
Asked by RAM MOHAN RAO | Dec 19, 2010 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi Ram,

Mail me your code.. let me check and reply u back...
Dec 22, 2010