Skip to content

Commit 56bcd60

Browse files
committed
fixed error by fixing syntaxerror
1 parent d2bfb65 commit 56bcd60

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

  • Sprint-3/1-key-errors

‎Sprint-3/1-key-errors/0.js‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3+
// fixing errors in the code to get the right result
34

45
// call the function capitalise with a string input
6+
//console.log(capitalise("hello"));
7+
58
// interpret the error message and figure out why an error is occurring
9+
// str has already been declared in function as a parameter, so we need to change str in let declaration and change names of the identifier in let declaration.
610

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

1216
// =============> write your explanation here
17+
18+
//The function is to capitalise a word or sentence to a uppercase.
19+
// when i tested the code it didn't work and i received a Syntexerror message which said that the identifier `str`has already been declared
20+
//it was declared in the function and repeatedly twice and tried to create a variable with let when this is already a parameter.
21+
//
22+
1323
// =============> write your new code here
24+
25+
function capitalise(str) {
26+
let string = `${str[0].toUpperCase()}${str.slice(1)}`;
27+
return string;
28+
}
29+
30+
console.log(capitalise("hello"));

0 commit comments

Comments
 (0)