
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DNA to RNA Conversion Using JavaScript
DNA And RNA Relation
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').
Problem
We are required to write a JavaScript function which translates a given DNA string into RNA.
Example
Following is the code −
const DNA = 'GCAT'; const DNAtoRNA = (DNA) => { let res = ''; for(let i = 0; i < DNA.length; i++){ if(DNA[i] === "T"){ res += "U"; }else{ res += DNA[i]; }; }; return res; }; console.log(DNAtoRNA(DNA));
Output
GCAU
Advertisements