Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Use javascript loops..
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Jeevan kumar
Use javascript loops..
1 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


Write a JavaScript code to find a number of unique letters in string. (Eg. if keyword is Tajmahal, Tajmahal count will be '5' , it only takes these letters T,j,m,h,l , not taken the letter a because it is repeated) , means it doesn't count the repeated letters.


Advertisement
View Answers

October 26, 2010 at 3:00 PM


Hello Friend,

Try the following code:

<script>
var st  = window.prompt("Enter string: ");
var arr=st.split("");
          var resulted = new Array();
          for (var j=0; j<arr.length; j++) {
              var key = arr[j].toString();
              if (!resulted[key]) {
                  resulted[key] = 1
              } else {
                  resulted[key] = resulted[key] + 1;
              }
          }
          var str = "";
          for (var j in results) {
          if(resulted[j]==1){
          str += j;
           }
          }
          alert(str.length);
</script>

Thanks



Related Tutorials/Questions & Answers:
Use javascript loops..
Use javascript loops..  Write a Javascript code to create a redirection script based on day of the week
Use javascript loops..
Use javascript loops..  Write a JavaScript code to find a number of unique letters in string. (Eg. if keyword is Tajmahal, Tajmahal count will be '5' , it only takes these letters T,j,m,h,l , not taken the letter a because
Advertisements
Use javascript loops..
Use javascript loops..  Write a Javascript code, so that numbers...(" "); for(var k=q; k>=1;k--){ document.write(" "); } for(var j=1;j<=i;j++){ document.write(" "); document.write(j); } document.write("<br>"); q
Javascript loops
Javascript loops  Write a JavaScript code, - for guessing any number between 1 to 20. run the loop till you not get correct number. Use prompt...: <SCRIPT LANGUAGE="JavaScript"> var guess; var rno=Math.round(Math.random
use of loops and screenshots
use of loops and screenshots  1.how to use loops in netbeans? 2.how to draw a correct screenshot
Solve using only Javascript loops...
Solve using only Javascript loops...  Write a JavaScript code, 1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique count will be '4') 2) so that numbers appear in following format, 1 1 2
JavaScript Loops Function
JavaScript Loops Types: In Java programming language a loop is a language... a function or method calls itself). JavaScript provides for, while, do-while, and foreach loop. Following examples will help you to learn loops: JavaScript Loop
Loops
Loops  ??Using for loops, Write a program to simulate a clock countdown. The program prompts the user to enter the number of seconds, displays a message at every second, and terminates when the time expires. Use method
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Loops
Loops  Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1
Loops
Loops  by using drjava q1.Write code that uses nested loops to print the following patterns: Pattern1: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 Pattern 2: 1 2 3 4 5 6 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1 q2.Write code
loops
loops  how to use for loop and while loop in java?/ how to write a code using for or while loop
use strings as array indexes using JavaScript
use strings as array indexes using JavaScript  How to use strings as array indexes using JavaScript
Loops
3.10. Loops Loops are the essential part of the program that have.... More than one loops can be used several times in a script. Loops makes easy... instructed for repetition of the code. PHP Loops In PHP, like other programming
Can i use Scriptlets inside javascript,if so how?
Can i use Scriptlets inside javascript,if so how?  Can i use Scriptlets inside javascript,if so how
nested for loops
"); } } } }   Close your loops before going
Java - Declaring variables in for loops
Java - Declaring variables in for loops  Java - Declaring variables in for loops
how to use javascript in jsf - Java Server Faces Questions
how to use javascript in jsf  Hi, how to use javascript in jsf... example. Thanks in advance  Hi friend, Using Javascript in JSF Javascript with a commandLink is not difficult,and understand how
Using Nested loops
Using Nested loops  How to use nested loops in java when I want to print the 10 multiples of numbers 2 to 15(in multiplication table)   public class MultiplicationTable{ public static void main(String[] args) { int
pattern-using loops
pattern-using loops  Write a program that displays the following pattern ... (use nested loops) * ** * ** * ** *   the correct pattren
how to use javascript drag and drop files upload - Ajax
how to use javascript drag and drop files upload  Hi,Sir Please, I would like to upload multiple files using javascript with drag and drop style.I have asked to you similar problem recently.You answer to me to use java applet
How to read loops in Java
How to read loops in Java  Example that explains how to read loop in Java
loops , control structures
loops , control structures  a simple java program to print 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1
LOOPS - Java Interview Questions
LOOPS   how to find out unique number of elements in given array?{1,2,5,3,2,1,1,7,2,3,0,1,5} output is: 1-4 2-3 3-2 5-2 0-1 7-1 i want source code plz help me
Arrays, loops and string handling
Arrays, loops and string handling  How would i go about in creating a program to mark and grade a set of multiple choice test results... for a student name and therafter for the students 10 answers. use input dialog
while loop to for loops
while loop to for loops  I have to change this while loops to for loops and I was wondering if you could help me out. I got the codes just need to know how to change it. int currentNum= num1; while(num1>num2
LOOPS !! - Java Interview Questions
LOOPS !!  i have string "Hello" i want to print like H He Hel Hell Hello o ol oll olle olleh i want source code plz help me?  String s="Hello"; System.out.println(s.length()); System.out.println
Advertisements
 

 

 

DMCA.com