【One topic per day】Isograms

前端题库,Javascript题集

Posted by Jerry on April 9, 2019

Isograms

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

reply

function isIsogram(str){
  return new Set(str.toUpperCase()).size == str.length;
}

同Github,欢迎star