Sha256: e256d04b91aa116c3a82ba462a4866dfd515dc6c987783158b9198cd9037ca74

Contents?: true

Size: 353 Bytes

Versions: 30

Compression:

Stored size: 353 Bytes

Contents

const DNA_TO_RNA = {
  G: "C",
  C: "G",
  T: "A",
  A: "U"
};

export default class Transcriptor {
  toRna(dna) {
    let rna = dna.replace(/./g, nucleotide => DNA_TO_RNA[nucleotide])

    if (rna.length !== dna.length) {
      // invalid characters in the strand
      throw new Error('Invalid input DNA.');
    } else {
      return rna;
    }
  }
}

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
trackler-2.2.0.0 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.55 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.54 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.53 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.52 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.51 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.50 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.49 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.48 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.47 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.46 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.45 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.44 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.43 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.42 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.41 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.40 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.39 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.38 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.37 tracks/ecmascript/exercises/rna-transcription/example.js