24 | Anagram Checker |
Using functions to abstract the logic away from the rest of your code makes it easier to read and easier to maintain.
Create a program that compares two strings and determines if the two strings are anagrams. The program should prompt for both input strings and display the output as shown in the example that follows.
Example Output
| Enter two strings and I'll tell you if they |
| are anagrams: |
| Enter the first string: note |
| Enter the second string: tone |
| "note" and "tone" are anagrams. |
Constraints
-
Implement the program using a function called isAnagram, which takes in two words as its arguments and returns true or false. Invoke this function from your main program.
-
Check that both words are the same length.
Challenge
-
Complete this ...
Get Exercises for Programmers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.