題目連結:
解法:
function DNAStrand(dna){
return dna.replace(/[ACTG]/g, match =>{
switch(match){
case "A":
return "T";
case "T":
return "A";
case "C":
return "G";
case "G":
return "C";
}
})
}
筆記:
替換字先想到replace()
/[ATCG]/g:找到所有A、T、C、G四個字母
switch()將傳遞進來的值通過case轉換成另外一個字

![[02] Functional Component](https://static.coderbridge.com/img/m6fish/ca3eb6ecdb8a4526b545ff99e7202a2a.jpg)
