Sha256: 8bc32024b61889bd97aac15f8d7ac498c7e5147292b8d8b7c71c2c91f9c5e5fd

Contents?: true

Size: 652 Bytes

Versions: 68

Compression:

Stored size: 652 Bytes

Contents

class NucleotideCount {
  static nucleotideCounts(strand: string) {
    const nucleotideOccurrences = {
      A: 0,
      C: 0,
      G: 0,
      T: 0
    }

    strand.split('').forEach((nucleotide) => {
      if (nucleotide in nucleotideOccurrences) {
        if (nucleotide === 'A') {nucleotideOccurrences.A++}
        if (nucleotide === 'C') {nucleotideOccurrences.C++}
        if (nucleotide === 'G') {nucleotideOccurrences.G++}
        if (nucleotide === 'T') {nucleotideOccurrences.T++}
      } else {
        throw new Error('Invalid nucleotide in strand')
      }
    })

    return nucleotideOccurrences
  }
}

export default NucleotideCount

Version data entries

68 entries across 68 versions & 1 rubygems

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