You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The anagram function should return false if both words are the same or when one or both strings are empty.
Of course more could be done to remove special characters & numbers to clean the incoming values.
Currently invoking the following returns true but should be false:
The text was updated successfully, but these errors were encountered:
fewdn
changed the title
19 anagram - The anagram function fails to test for duplicate values or empty values
18 anagram - The anagram function fails to test for duplicate values or empty values
Jan 6, 2025
fewdn
changed the title
18 anagram - The anagram function fails to test for duplicate values or empty values
18-6 Anagram - The anagram function fails to test for duplicate values or empty values
Jan 6, 2025
https://github.com/bradtraversy/javascript-sandbox/blob/main/18-unit-testing-algorithms/06-anagrams/algo-testing/anagram/anagram.js
The updated file can be found here:
PacktPublishing#3
The anagram function should return false if both words are the same or when one or both strings are empty.
Of course more could be done to remove special characters & numbers to clean the incoming values.
Currently invoking the following returns true but should be false:
anagram("pop", "pop");
anagram("", "");
anagram(" ", " ");
The quick fix could be a conditional and remove whitespace with replaceAll().
Or, clean the string of special characters, numbers & whitespace, using a Regular Expression, then compare:
The text was updated successfully, but these errors were encountered: