Skip to content

Commit c9493c5

Browse files
authored
Completed part 3
1 parent a71e711 commit c9493c5

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
//Part Three section one
1+
// Part Three section one
22

33
let language = 'JavaScript';
44

5-
//1. Use string concatenation and two slice() methods to print 'JS' from 'JavaScript'
5+
// 1. Use string concatenation and two slice() methods to print 'JS' from 'JavaScript'
6+
let abbreviation = language.slice(0, 1) + language.slice(4, 5);
7+
console.log(abbreviation); // Prints 'JS'
68

7-
//2. Without using slice(), use method chaining to accomplish the same thing.
9+
// 2. Without using slice(), use method chaining to accomplish the same thing.
10+
abbreviation = language.charAt(0) + language.charAt(4);
11+
console.log(abbreviation); // Prints 'JS'
812

9-
//3. Use bracket notation and a template literal to print, "The abbreviation for 'JavaScript' is 'JS'."
13+
// 3. Use bracket notation and a template literal to print, "The abbreviation for 'JavaScript' is 'JS'."
14+
console.log(`The abbreviation for '${language}' is '${language[0]}${language[4]}'.`);
1015

11-
//4. Just for fun, try chaining 3 or more methods together, and then print the result.
16+
// 4. Just for fun, try chaining 3 or more methods together, and then print the result.
17+
let funResult = language.toLowerCase().replace('java', 'ecma').toUpperCase();
18+
console.log(funResult); // Prints 'ECMASCRIPT'
1219

13-
//Part Three section Two
14-
15-
//1. Use the string methods you know to print 'Title Case' from the string 'title case'.
20+
// Part Three section two
1621

22+
// 1. Use the string methods you know to print 'Title Case' from the string 'title case'.
1723
let notTitleCase = 'title case';
24+
let titleCase = notTitleCase
25+
.split(' ')
26+
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
27+
.join(' ');
28+
console.log(titleCase); // Prints 'Title Case'

0 commit comments

Comments
 (0)