-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa1c93b
commit ee304cc
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
*An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case. | ||
*isIsogram("Dermatoglyphics") == true | ||
*isIsogram("aba") == false | ||
*isIsogram("moOse") == false // -- ignore letter case | ||
**/ | ||
|
||
/** | ||
*Set's size should be equal to string length | ||
**/ | ||
function isIsogram(str){ | ||
const set = new Set(); | ||
for(let i=0;i<str.toLowerCase().length;i++) { | ||
set.add(str.charAt(i)); | ||
} | ||
return str.length === set.size; | ||
} |