Advertisement
dabidabidesh

Print DNA

May 19th, 2020
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //15 EXERCISE: FUNCTIONS/More Exercise/05. Print DNA.js
  2. printDna0(14)
  3.  
  4. function printDna0(n) {
  5.   'use strict'
  6.  
  7.   const seq = 'ATCGTTAGGG'
  8.   const temp = ['**AB**', '*A--B*', 'A----B', '*A--B*']
  9.  
  10.   let i = 0
  11.   let j = 0
  12.   let k = 0
  13.   while (j !== n) {
  14.     let ch1 = seq[i]
  15.     let ch2 = seq[i + 1]
  16.     let str = temp[k].replace('A', ch1)
  17.     str = str.replace('B', ch2)
  18.     console.log(str)
  19.     j++
  20.     i += 2
  21.     if (i === 10)
  22.       i = 0
  23.     k++
  24.     if (k === 4)
  25.       k = 0
  26.   }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement