Skip to content

Commit 2b346b8

Browse files
committed
added starter code for exercises and legacy repl.it code
1 parent e0f20f8 commit 2b346b8

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let jsCreator = "Brendan Eich";
2+
3+
console.log(jsCreator[-1]);
4+
console.log(jsCreator[42]);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let pluralNoun = ;
2+
let name = ;
3+
let verb = ;
4+
let adjective = ;
5+
let color = ;
6+
7+
console.log("JavaScript provides a "+ color +" collection of tools — including " + adjective + " syntax and " + pluralNoun + " — that allows "+ name +" to "+ verb +" with strings.")
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//String methods can be combined in a process called method chaining.
2+
3+
let word = 'JavaScript';
4+
5+
console.log(word.toUpperCase());
6+
//Returns ``JAVASCRIPT``
7+
8+
//What does ``word.slice(4).toUpperCase()`` return?
9+
10+
11+
//Experiment with other combinations (chains) of string methods.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let num = 1001;
2+
3+
//Returns 'undefined'.
4+
console.log(num.length);
5+
6+
//Use type conversion to print the length (number of digits) of an integer.
7+
8+
//Follow up: Print the number of digits in a DECIMAL value (e.g. num = 123.45 has 5 digits but a length of 6).
9+
10+
//Experiment! What if num could be EITHER an integer or a decimal? Add an if/else statement so your code can handle both cases.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//Part Three section one
2+
3+
let language = 'JavaScript';
4+
5+
//1. Use string concatenation and two slice() methods to print 'JS' from 'JavaScript'
6+
7+
//2. Without using slice(), use method chaining to accomplish the same thing.
8+
9+
//3. Use bracket notation and a template literal to print, "The abbreviation for 'JavaScript' is 'JS'."
10+
11+
//4. Just for fun, try chaining 3 or more methods together, and then print the result.
12+
13+
//Part Three section Two
14+
15+
//1. Use the string methods you know to print 'Title Case' from the string 'title case'.
16+
17+
let notTitleCase = 'title case';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//Part Two Section One
2+
3+
let dna = " TCG-TAC-gaC-TAC-CGT-CAG-ACT-TAa-CcA-GTC-cAt-AGA-GCT ";
4+
5+
// First, print out the dna strand in it's current state.
6+
7+
//1) Use the .trim() method to remove the leading and trailing whitespace, then print the result.
8+
9+
console.log(/* Your code here. */);
10+
11+
//2) Change all of the letters in the dna string to UPPERCASE, then print the result.
12+
13+
console.log();
14+
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+
//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);
19+
20+
//Part Two Section Two
21+
22+
let dnaTwo = "TCG-TAC-GAC-TAC-CGT-CAG-ACT-TAA-CCA-GTC-CAT-AGA-GCT";
23+
24+
//1) Replace the gene "GCT" with "AGG", and then print the altered strand.
25+
26+
//2) Look for the gene "CAT" with ``indexOf()``. If found print, "CAT gene found", otherwise print, "CAT gene NOT found".
27+
28+
//3) Use .slice() to print out the fifth gene (set of 3 characters) from the DNA strand.
29+
30+
//4) Use a template literal to print, "The DNA strand is ___ characters long."
31+
32+
//5) Just for fun, apply methods to ``dna`` and use another template literal to print, 'taco cat'.

0 commit comments

Comments
 (0)