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.180 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/anagram/anagram.example.ts