|
3 | 3 | let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT ";
|
4 | 4 |
|
5 | 5 | // First, print out the dna strand in it's current state.
|
6 |
| - |
| 6 | +console.log(dna) |
7 | 7 | //1) Use the .trim() method to remove the leading and trailing whitespace, then print the result.
|
8 |
| - |
9 |
| -console.log(/* Your code here. */); |
| 8 | +let dna2 = dna.trim() |
| 9 | +console.log(dna2/* Your code here. */); |
10 | 10 |
|
11 | 11 | //2) Change all of the letters in the dna string to UPPERCASE, then print the result.
|
12 | 12 |
|
13 |
| -console.log(); |
| 13 | +console.log(dna.toUpperCase()); |
14 | 14 |
|
15 | 15 | //3) Note that after applying the methods above, the original, flawed string is still stored in dna. To fix this, we need to reassign the changes to back to dna.
|
16 | 16 | //Apply these fixes to your code so that console.log(dna) prints the DNA strand in UPPERCASE with no whitespace.
|
17 |
| - |
18 |
| -console.log(dna); |
| 17 | +dna = "TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT" |
| 18 | +console.log(dna.toUpperCase()); |
19 | 19 |
|
20 | 20 | //Part Two Section Two
|
21 | 21 |
|
22 | 22 | let dnaTwo = "TCG-TAC-GAC-TAC-CGT-CAG-ACT-TAA-CCA-GTC-CAT-AGA-GCT";
|
23 | 23 |
|
24 | 24 | //1) Replace the gene "GCT" with "AGG", and then print the altered strand.
|
25 | 25 |
|
26 |
| -//2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found". |
| 26 | +console.log(dnaTwo.replace("GCT","AGG")) |
27 | 27 |
|
| 28 | +//2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found". |
| 29 | +let indexOf = "CAT"; |
| 30 | +if (String(dnaTwo).includes("CAT")){ |
| 31 | + console.log("CAT gene found."); |
| 32 | +} else {console.log("CAT gene not found"); |
| 33 | +} |
28 | 34 | //3) Use .slice() to print out the fifth gene (set of 3 characters) from the DNA strand.
|
29 | 35 |
|
30 |
| -//4) Use a template literal to print, "The DNA strand is ___ characters long." |
| 36 | +console.log(String(dnaTwo.indexOf('CGT'))); |
| 37 | +console.log(String(dnaTwo.indexOf('-CAG'))) |
| 38 | +console.log(String(dnaTwo.slice(16,19))) |
| 39 | +//used the index to find the beginning and ending of the desired strand, within the string; and sliced it with corresponding numbers// |
31 | 40 |
|
| 41 | +//4) Use a template literal to print, "The DNA strand is ___ characters long." |
| 42 | +console.log(dnaTwo.length) |
| 43 | +let dnaLength = 51; |
| 44 | +let variable1 = "DNA strand" |
| 45 | +let tc = 'taco cat' |
| 46 | +console.log(`"The ${variable1} is ${dnaLength} characters long."`); |
32 | 47 | //5) Just for fun, apply methods to ``dna`` and use another template literal to print, 'taco cat'.
|
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +console.log(`"The temperature of the ${variable1} varies on the number of characters a ${variable1} has. \n |
| 53 | +So if there are ${dnaLength} characters, the temp will be just right to produce a ${tc}."`) |
| 54 | + |
0 commit comments