Skip to content

Commit 7d6b8da

Browse files
committed
Fix SyntaxError
1 parent 7fd4ee0 commit 7d6b8da

File tree

1 file changed

+12
-4
lines changed
  • Sprint-2/1-key-errors

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,23 @@
44
// call the function capitalise with a string input
55
// interpret the error message and figure out why an error is occurring
66

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

1212
// =============> write your explanation here
1313

1414
// Error at line 8
1515
//SyntaxError: Identifier 'str' has already been declared
16+
// the function has alreayd a parameter called "str"and
17+
// we are trying decare a new variable with the same name
1618

1719
// =============> write your new code here
1820

21+
function capitalise(str) {
22+
let newCap = `${str[0].toUpperCase()}${str.slice(1)}`;
23+
return newCap;
24+
}
25+
console.log(capitalise("hello"));
26+
console.log(capitalise("apple"));

0 commit comments

Comments
 (0)