DEV Community

Discussion on: Daily Challenge #159 - Isogram

Collapse
 
samwatts98 profile image
Sam Watts • Edited

Here’s my JS implementation using .reduce() :) :

 const isIsogram = word => {
  word = word.toLowerCase().split(“”)
  const result = word.reduce((accum, letter) => {
    !accum.includes(letter) && accum.push(letter);
    return accum;
  }, []);
  return result.length === word.length;
}
Collapse
 
samwatts98 profile image
Sam Watts

Hindsight, @savagepixie ’s answer using sets was much better and more efficient! Set theory is always better in situations like this :)

Collapse
 
savagepixie profile image
SavagePixie

To be fair, Set usually isn't my first thought when solving problems. It's one of those things I kinda know are there but don't use that often.