Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed return value of the Map version #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixed return value of the Map version #19

wants to merge 1 commit into from

Conversation

GomuGilad6
Copy link

If the for loop finishes without returning false, it will always return true.
Both strings have the same length at this point (if not, the function will return false at its beginning).
So if a character exists in one string and not the other, count will be undefined, and the function will return false.
The function will always return true if it finishes the for loop as the map size will be 0, so might as well return true (could be confusing as to why you have to return the map size).

If the for loop finishes without returning false, it will always return true.
Both strings have the same length at this point (if not, the function will return false at its beginning).
So if a character exists in one string and not the other, count will be undefined, and the function will return false.
The function will always return true if it finishes the for loop as the map size will be 0, so might as well return true (could be confusing as to why you have to return the map size).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant