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.139 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.138 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.137 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.136 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.135 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.134 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.133 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.132 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.131 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.130 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.129 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.128 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.127 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.126 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.125 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.124 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.123 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.122 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.121 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.120 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts