Why won’t this one case work? I know how to solve it after reading a medium post, but I’m trying to find the error in this one case.
Here’s my code
Why won’t this one case work? I know how to solve it after reading a medium post, but I’m trying to find the error in this one case.
Here’s my code
You should return true;
after you have checked every element in the array, and are sure that all letters match. In your code you are returning true
prematurely, before the loop finishes checking each letter.
Bonus: Next time instead of posting a screenshot of the code, paste the code instead, so it’s easy to copy/paste to a code editor.