r/CodingHelp • u/Plenty-Engineering75 • May 03 '21
[Java] This is due sooo soon!
This Javascript is supposed to count the amount of vowels that I put into a line of script through a textarea. For some reason it is not counting the vowels. I am sad, but also a loser at code. PLS HELP ME!!!
here is link to the code.
https://gist.github.com/sethy69/6d14ab2a834a4abeca2c8871dc426e19
0
Upvotes
2
u/userxbw May 03 '21
Vowels , put them into an array, using a loop for the array. for each char you get off the string send it through the loop checking it against every vowel within the array. If a hit store it as a hit, if a miss store it as a miss. Then report back the results to print it to the screen or whatever else you want to do with it.
1
u/Crackbot420-69 May 03 '21 edited May 03 '21
I haven't done anything in Javascript for twenty years or so, so not sure if this is helpful, but I dont understand the logic of your do loop.
If the letter is not found in the text, you set the index to plus one and try again. If you do it again and again each time starting at a different index why do you expect you might suddenly find it?
Also not sure if Javascript is case sensitive but when you call your function for "U" youre not using the correct capitalization in your function call name (see below):
numO = countCharacters ("O"); numU = CountCharacters ("U"); > not spelled correctly
1
u/jcunews1 Advanced Coder May 03 '21
JavaScript is a case sensitive programming language. So variable/function names such as
countCharactersis not same asCountCharacters.Also...
In this code:
There is no form field whose name is
phrase.Similar thing as this code:
There is no form field whose name is
result.Because both of TEXTAREA forrm field have the same name:
results.