Skip to content

Commit c521ac2

Browse files
Add answers and write new code to effect changes.
1 parent 3372770 commit c521ac2

File tree

1 file changed

+15
-3
lines changed
  • Sprint-2/1-key-errors

1 file changed

+15
-3
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// I thought it was going to work, however my prediction was wrong. =============> write your prediction here
33

44
// call the function capitalise with a string input
5+
6+
//SyntaxError: Identifier 'str' has already been declared
7+
8+
59
// interpret the error message and figure out why an error is occurring
610

711
function capitalise(str) {
812
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
913
return str;
1014
}
1115

12-
// =============> write your explanation here
13-
// =============> write your new code here
16+
17+
18+
19+
// The identifier "str" has already been declared as a parameter in the function and cannot be redeclared withing a block scope.// =============> write your explanation here
20+
21+
22+
function capitalise(str) {
23+
return `${str[0].toUpperCase()}${str.slice(1)}`;
24+
}
25+
// =============> write your new code here

0 commit comments

Comments
 (0)