Skip to content

Commit a6c092d

Browse files
committed
submitted completed task
1 parent be6a3b0 commit a6c092d

File tree

1 file changed

+10
-2
lines changed
  • Sprint-2/1-key-errors

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,19 @@
33

44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
6-
6+
/*
77
function capitalise(str) {
88
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
99
return str;
1010
}
11-
11+
*/
1212
// =============> write your explanation here
13+
//Undeclared variables are automatically declared when first used. As a parameter in the 'capitalise' function,
14+
// 'str' is already declared. trying to declare it again with 'let' will cause a syntax error.
15+
1316
// =============> write your new code here
17+
function capitalise(str) {
18+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
19+
return str;
20+
}
21+
console.log(capitalise("hello world")); // This line is inserted only to test the code. It returns "Hello world"

0 commit comments

Comments
 (0)