Sha256: 02753bfb5e8f3a8191fb9c82b4e83a3fded88d02e01a6aadce87f6ceb67211f5

Contents?: true

Size: 571 Bytes

Versions: 241

Compression:

Stored size: 571 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

241 entries across 241 versions & 1 rubygems

Version Path
trackler-2.2.1.125 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.124 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.123 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.122 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.121 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.120 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.119 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.118 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.117 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.116 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.115 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.114 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.113 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.111 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.110 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.109 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.108 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.107 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.106 tracks/typescript/exercises/anagram/anagram.example.ts
trackler-2.2.1.105 tracks/typescript/exercises/anagram/anagram.example.ts