Sha256: cf67906d780e16a4dd1196a9a64cc3805dd62c6a22ffde9ed906bf96f63bac23

Contents?: true

Size: 404 Bytes

Versions: 71

Compression:

Stored size: 404 Bytes

Contents

const count = (str, nuc) => [...str].filter(nucleotide => nucleotide === nuc).length;

class NucleotideCounts {
  static parse(strand) {
    if (strand.replace(/A|C|G|T/g, '').length) {
      throw new Error('Invalid nucleotide in strand');
    } else {
      return `${count(strand, 'A')} ${count(strand, 'C')} ${count(strand, 'G')} ${count(strand, 'T')}`;
    }
  }
}

export default NucleotideCounts;

Version data entries

71 entries across 71 versions & 1 rubygems

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