It may be a correct algorithm but the implementation is not a very good one. The countVowelsRecursive should be a pure function and not depend to scoped count variable. What happens when we run the countVowelsRecursive twice in the same code snippet? Is the result of the 1st call the same as the 2nd?
Senior Full Stack Engineer with experience in modern Server-less architectures. Svelte & TS user and advocate on everything JAM-stack. Excited around the future of web development.
No worries, you can make it a function in a function with the parent one having the count = 0 and then the child one doing the iteration. Though you got the point that the idea behind it was to showcase different algorithms, right ?
Yeah, i mentioned that the algorithm is correct at the beginning. But i felt the urge to comment about the implementation because i think it matters. Nevermind, the topic is about the algorithm so let's move on.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It may be a correct algorithm but the implementation is not a very good one. The
countVowelsRecursive
should be a pure function and not depend to scopedcount
variable. What happens when we run thecountVowelsRecursive
twice in the same code snippet? Is the result of the 1st call the same as the 2nd?No worries, you can make it a function in a function with the parent one having the count = 0 and then the child one doing the iteration. Though you got the point that the idea behind it was to showcase different algorithms, right ?
Yeah, i mentioned that the algorithm is correct at the beginning. But i felt the urge to comment about the implementation because i think it matters. Nevermind, the topic is about the algorithm so let's move on.