Todorov_Stanimir

05. Print DNA Functions - More Exercise

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