Skip to content

Commit 7db8109

Browse files
committed
Modified
1 parent 927521c commit 7db8109

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed
Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
1-
let count = 0;
1+
//let count = 0;
22

3-
count = count + 1;
3+
//count = count + 1;
44

55
// Line 1 is a variable declaration, creating the count variable with an initial value of 0
66
// Describe what line 3 is doing, in particular focus on what = is doing
77
// Line 3 returns the incremented value of count. The operator = assigns count +1 to the varibale count in the
88
// left.
99

10-
// Described what line three is doing.
10+
// Described what line three is doing.
11+
12+
function drawStairs(n) {
13+
let result = "";
14+
if (n < 1) return result; // nothing to do
15+
16+
let iCount = 0;
17+
while (iCount < n) {
18+
// add spaces before the I (for all lines after the first)
19+
let spaceCount = 0;
20+
while (spaceCount < iCount) {
21+
result = result.concat(" ");
22+
spaceCount = spaceCount + 1;
23+
}
24+
25+
// add the "I"
26+
result = result.concat("I");
27+
28+
// add a newline after each line except the last one
29+
if (iCount < n - 1) {
30+
result = result.concat("\n");
31+
}
32+
33+
// update the count
34+
iCount = iCount + 1;
35+
}
36+
37+
return result;
38+
}
39+
40+
console.log(drawStairs(10));

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,14 @@ console.log(initials)
1313

1414
// Declared a variable named initials
1515

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));
26+

Sprint-1/2-mandatory-errors/2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
const cityOfBirth = "Bolton";
66
console.log(`I was born in ${cityOfBirth}`);
77

8-
// Problem fixed
8+
// Problem has been fixed
99

0 commit comments

Comments
 (0)