#Counting the number of specific letter in the text

14 messages · Page 1 of 1 (latest)

keen anvil
#

Hello.
With an array it's easy to count the number (using an index), but how do I count the number of any letter in a string?
I tried to generate the algorithm but it prints 28 which is wrong

distant agateBOT
#

This post has been reserved for your question.

Hey @keen anvil! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

broken vault
#

look at your loop. what's it doing?

#

i isn't being used, so there's nothing different between each iteration.

#

try looking at your code for checking an array

#

a string is a sequence of characters, you can use it similarly to an array to get each element, just with a method instead of indexing syntax

keen anvil
distant agateBOT
broken vault
#

you can access individual characters in the string directly

#

it's ||char charAt(int index)||

keen anvil
distant agateBOT
# keen anvil Thank you very much for your help.

If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.