Skip to content

Commit

Permalink
Create Isogram.js
Browse files Browse the repository at this point in the history
  • Loading branch information
creativesuraj authored Apr 4, 2020
1 parent fa1c93b commit ee304cc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Isogram.js
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;
}

0 comments on commit ee304cc

Please sign in to comment.