count character in one sentence

can anyone help me in this situation....

we prompt user to enter a sentence, then we count the number of charaters of the sentence; how many 'a', how many 'b'.......
by using javascript.

please explain and provide an example for me, thanks!

Comments

  • : can anyone help me in this situation....
    :
    : we prompt user to enter a sentence, then we count the number of charaters of the sentence; how many 'a', how many 'b'.......
    : by using javascript.
    :
    : please explain and provide an example for me, thanks!
    :
    [code]
    Set up an array of ints for each character ' ' thru 'z'
    (32 thru 122, 91 element array, maybe called chrs)
    Loop thru the sentence entered, for each character:
    subtract 32 (giving ch)
    if >= 0 and <= 90
    increment chrs[ch]
    [/code]

    ----------------
    Walt


  • : : can anyone help me in this situation....
    : :
    : : we prompt user to enter a sentence, then we count the number of charaters of the sentence; how many 'a', how many 'b'.......
    : : by using javascript.
    : :
    : : please explain and provide an example for me, thanks!
    : :
    : [code]
    : Set up an array of ints for each character ' ' thru 'z'
    : (32 thru 122, 91 element array, maybe called chrs)
    : Loop thru the sentence entered, for each character:
    : subtract 32 (giving ch)
    : if >= 0 and <= 90
    : increment chrs[ch]
    : [/code]
    :
    : ----------------
    : Walt
    :
    : actually i not really know how to declare a a array variable in javascript, can u give me a example?

    by the way, after i declare the charater array, can i use switch/case to check for the how many character 'a', 'b', 'c' and so on?

    if yes, provide me example too, thanks and sorry for inconvience!
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion