Skip to content

Commit d7e27ee

Browse files
author
Edward King
committed
Part 2 Complete
1 parent 1d5cb9d commit d7e27ee

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed
Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,37 @@
11
//Part Two Section One
22

3-
let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT ";
3+
let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT ".trim().toUpperCase();
44

55
// First, print out the dna strand in it's current state.
6-
6+
console.log(dna);
77
//1) Use the .trim() method to remove the leading and trailing whitespace, then print the result.
8-
9-
console.log(/* Your code here. */);
10-
8+
let newDna = dna.trim();
9+
console.log(newDna);
1110
//2) Change all of the letters in the dna string to UPPERCASE, then print the result.
12-
13-
console.log();
11+
let dnaUpper = dna.toUpperCase();
12+
console.log(dnaUpper);
1413

1514
//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.
1615
//Apply these fixes to your code so that console.log(dna) prints the DNA strand in UPPERCASE with no whitespace.
1716

18-
console.log(dna);
17+
//console.log(dna);
1918

2019
//Part Two Section Two
2120

2221
let dnaTwo = "TCG-TAC-GAC-TAC-CGT-CAG-ACT-TAA-CCA-GTC-CAT-AGA-GCT";
23-
22+
console.log(dnaTwo.indexOf('CAT'));
2423
//1) Replace the gene "GCT" with "AGG", and then print the altered strand.
25-
24+
let dnaTwoReplace = dnaTwo.replace('GCT', 'AGG');
25+
console.log(dnaTwoReplace);
2626
//2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found".
27-
27+
if (dnaTwo.indexOf("CAT") === 40){
28+
console.log("CAT gene found");
29+
}else{
30+
console.log("CAT gene NOT found");
31+
}
2832
//3) Use .slice() to print out the fifth gene (set of 3 characters) from the DNA strand.
29-
33+
console.log(dnaTwo.slice(16, 19));
3034
//4) Use a template literal to print, "The DNA strand is ___ characters long."
31-
35+
console.log(`The DNA strand is ${dnaTwo.length} characters long`);
3236
//5) Just for fun, apply methods to ``dna`` and use another template literal to print, 'taco cat'.
37+
console.log(`${dna.slice(4,7).toLowerCase()}o ${dna.slice(dna.indexOf('CAT'),dna.indexOf('CAT')+3).toLowerCase()}`);

0 commit comments

Comments
 (0)