Skip to content

Commit afca59a

Browse files
committed
Refactor comments for clarity and fix variable naming conflict in capitalise function
1 parent 76e3f65 commit afca59a

File tree

2 files changed

+25
-8
lines changed
  • Sprint-1/2-mandatory-errors
  • Sprint-2/1-key-errors

2 files changed

+25
-8
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
This is just an instruction for the first activity - but it is just for human consumption
2-
We don't want the computer to run these 2 lines - how can we solve this problem?
1+
///This is just an instruction for the first activity - but it is just for human consumption
2+
//We don't want the computer to run these 2 lines - how can we solve this problem?
3+
4+
// in code use backslashes to create comments.

Sprint-2/1-key-errors/0.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,28 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> write your prediction here:
3+
// I think their will be an error because of the str tag
4+
5+
6+
7+
38

49
// call the function capitalise with a string input
10+
console.log(capitalise("hello")); // should print "Hello"
11+
12+
513
// interpret the error message and figure out why an error is occurring
614

7-
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10-
}
1115

12-
// =============> write your explanation here
16+
//function capitalise(str) {
17+
//let str = `${str[0].toUpperCase()}${str.slice(1)}`;
18+
//return str;
19+
//}
20+
21+
// =============> write your explanation here:
22+
// str is being used as both the function parameter and a variable inside the function, causing a conflict.
23+
24+
1325
// =============> write your new code here
26+
27+
function capitalise(inputStr) {
28+
return `${inputStr[0].toUpperCase()}${inputStr.slice(1)}`;}

0 commit comments

Comments
 (0)