Skip to content

Commit 5dab8a6

Browse files
committed
Used template string to display initials
1 parent 97637ad commit 5dab8a6

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

Sprint-1/1-key-exercises/1-count.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,16 @@ function drawStairs(n) {
4040
}
4141

4242
console.log(drawStairs(10));
43+
44+
/// Another example
45+
46+
function drawStairs(n) {
47+
let result = [];
48+
49+
for (let i = 0; i < n; i++) {
50+
result[i] = `${' '.repeat(i)}I`;
51+
}
52+
53+
return result.join('\n');
54+
}
55+
console.log(drawStairs(5));

Sprint-1/1-key-exercises/2-initials.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@ let lastName = "Johnson";
55
// Declare a variable called initials that stores the first character of each string.
66
// This should produce the string "CKJ", but you must not write the characters C, K, or J in the code of your solution.
77

8-
let initials = firstName[0]+middleName[0]+lastName[0];
8+
//let initials = firstName[0] + middleName[0] + lastName[0];
9+
10+
let initials = `${firstName[0]}${middleName[0]}${lastName[0]}`;
911

1012
console.log(initials)
1113

1214
// https://www.google.com/search?q=get+first+character+of+string+mdn
1315

1416
// Declared a variable named initials
1517

16-
function drawStairs(n) {
17-
let result = [];
18-
19-
for (let i = 0; i < n; i++) {
20-
result[i] = `${' '.repeat(i)}I`;
21-
}
22-
23-
return result.join('\n');
24-
}
25-
console.log(drawStairs(5));
18+
// Used template string to display initials Line 10
19+
20+
2621

0 commit comments

Comments
 (0)