Sha256: f8d03b96793838c96cab78554d1b1340ca90eb5464d167198b0ae0fdad492748

Contents?: true

Size: 357 Bytes

Versions: 153

Compression:

Stored size: 357 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

153 entries across 153 versions & 1 rubygems

Version Path
trackler-2.1.0.25 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.24 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.23 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.22 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.21 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.20 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.19 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.18 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.17 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.16 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.15 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.14 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.13 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.12 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.11 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.10 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.9 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.8 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.7 tracks/ecmascript/exercises/rna-transcription/example.js
trackler-2.1.0.6 tracks/ecmascript/exercises/rna-transcription/example.js