Sha256: a2c67ce59bc4b2e5f049ed876d8cc47915accdbad192915a507d311cc3940010

Contents?: true

Size: 572 Bytes

Versions: 54

Compression:

Stored size: 572 Bytes

Contents

function sort(input: string): string {
    return input.toString().toLowerCase().split("").sort().join("")
}

class Anagram {
    value: string
    constructor(input: string) {
        this.value = input
    }

    matches(...input: string[]): string[] {
        const result: string[] = []
        for (const each of input) {
            if (sort(each) === sort(this.value)) {
                if (each.toLowerCase() === this.value.toLowerCase()) { continue }
                result.push(each)
            }
        }
        return result
    }
}

export default Anagram

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.138 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.137 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.136 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.135 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.134 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.133 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.132 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.131 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.130 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.129 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.128 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.127 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.126 tracks/typescript/exercises/anagram/anagram.example.ts