Skip to content

Commit d0828f2

Browse files
committed
key error 0.js completed
1 parent ef676e6 commit d0828f2

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

  • Sprint-3/1-key-errors

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
/* =============> I predict that the function would make 1st character uppercase and
3+
then adds the rest of the string using slice. */
34

45
// call the function capitalise with a string input
56
// interpret the error message and figure out why an error is occurring
67

8+
//We cannot declare str again because it has already been declared as a parameter of the function.
9+
10+
/* OLD CODE
11+
712
function capitalise(str) {
813
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
914
return str;
1015
}
16+
*/
1117

1218
// =============> write your explanation here
1319
// =============> write your new code here
20+
21+
function capitalise(str) {
22+
str = `${str[0].toUpperCase()}${str.slice(1)}`;
23+
return str;
24+
}

0 commit comments

Comments
 (0)