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.159 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.158 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.157 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.156 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.155 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.154 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.153 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.152 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.151 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.150 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.149 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.148 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.147 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.146 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.145 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.144 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.143 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.142 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.141 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts
trackler-2.2.1.140 tracks/typescript/exercises/nucleotide-count/nucleotide-count.example.ts