-
Notifications
You must be signed in to change notification settings - Fork 0
/
19jul22SplitJoin.js
33 lines (25 loc) · 1.23 KB
/
19jul22SplitJoin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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').
Create a function which translates a given DNA string into RNA.
For example:
"GCAT" => "GCAU"
The input string can be of arbitrary length - in particular, it may be empty. All input is guaranteed to be valid, i.e. each input string will only ever consist of 'G', 'C', 'A' and/or 'T'.
function DNAtoRNA(dna) {
return dna.split('T').join('U')
}
// let newStr = ''
// let arr = dna.split('')
// arr.forEach(i =>
// { i.replace('T','U')
// newStr+= i;
// }) return newStr;
// let newStr = ''
// dna.split('').forEach(i=> {
// if(i === 'T') {i = 'U'
// return newStr+= i;
// }
// }) return newStr
// newStr+= i;
//dna is a string
//split the string
//if i of stirng is 'T' return 'U'