Преобразование ДНК в РНК в JavaScript

Create a function which translates a given DNA string into RNA.

Подскажите как сделать это?


Ответы (1 шт):

Автор решения: entithat

Нашел похожую задачу на codewars

Deoxyribonucleic acid, DNA is the primary information storage molecule in biological systems. It is composed of four nucleic acid bases Guanine ('G'), Cytosine ('C'), Adenine ('A'), and Thymine ('T').

Ribonucleic acid, RNA, is the primary messenger molecule in cells. RNA differs slightly from DNA its chemical structure and contains no Thymine. In RNA Thymine is replaced by another nucleic acid Uracil ('U').

Поэтому все, что нам требуется - это заменить тимин T на урацил U.

const dna = [
  'TTTT',
  'GCAT',
  'GATTCCACCGACTTCCCAAGTACCGGAAGCGCGACCAACTCGCACAGC'
];

console.log(dna.map(e => e.replace(/T/g, 'U')));

→ Ссылка