Sha256: b4c0f04450bc0c03d17795048c7285b9155c56c287199161f0cd08b5ba716d01

Contents?: true

Size: 642 Bytes

Versions: 295

Compression:

Stored size: 642 Bytes

Contents

class PhoneNumber {
    private value: string
    constructor(input: string) {
        let cleanedUp = input.replace(/(\)|\(|\s|\.|-)/g, "")
        if (cleanedUp.length === 11 && cleanedUp[0] === "1") {
            cleanedUp = cleanedUp.slice(1, 11)
        }
        this.value = cleanedUp
    }
    number(): string | undefined {
        if (this.value.length < 10 || this.value.length > 10 ) {
            return undefined
        }
        for (const each of this.value) {
           const result = parseInt(each, 10)
           if (isNaN(result)) {return undefined}
        }
        return this.value
    }
}
export default PhoneNumber

Version data entries

295 entries across 295 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.179 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.178 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.177 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.176 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.175 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.174 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.173 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.172 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.171 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.170 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.169 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.167 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.166 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.165 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.164 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.163 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.162 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.161 tracks/typescript/exercises/phone-number/phone-number.example.ts
trackler-2.2.1.160 tracks/typescript/exercises/phone-number/phone-number.example.ts