Todorov_Stanimir

05. Print DNA Functions - More Exercise

Jun 12th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function printDNA(num) {
  2.     let a = ['AT', 'CG', 'TT', 'AG', 'GG'];
  3.     let y = z = 0;
  4.     let step = 1;
  5.     for (let i = 0; i < num; i++) {
  6.         console.log('*'.repeat(2 - y) + a[z][0] + '-'.repeat(2 * y) + a[z][1] + '*'.repeat(2 - y));
  7.         y += step;
  8.         z++;
  9.         if (y === 2) {
  10.             step = -1;
  11.         }
  12.         if (y === 0) {
  13.             step = 1;
  14.         }
  15.         if (z === 5) {
  16.             z = 0;
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment