DEV Community

Discussion on: Python | Isogram Problem!

thinkverse profile image
Kim Hallberg • Edited on

Fun thing, the same code works in Javascript too with some small modifications.

function is_isogram (str) {
    const cleaned = str.replace('-', '').replace(' ', '').toLowerCase();
    return new Set(cleaned).size == cleaned.length;

console.log(is_isogram("lumberjacks")) // Returns true
console.log(is_isogram("background")) // Returns true
console.log(is_isogram("downstream")) // Returns true
console.log(is_isogram("six-year-old")) // Returns true
console.log(is_isogram("isograms")) // Returns false
console.log(is_isogram("\u0041\u0042\u0043"))  // Returns true
console.log(is_isogram("\u0041\u0061\u0042\u0043")) // Returns false