You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-2/1-key-errors/0.js
+8-1Lines changed: 8 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,7 @@
1
1
// Predict and explain first...
2
2
// =============> write your prediction here
3
+
// This function is trying to capitalise the first letter of a string.
4
+
// it takes the first character using str[0], converts it to uppercase,and joins it with the rest of the string using str.slice(1).
3
5
4
6
// call the function capitalise with a string input
5
7
// interpret the error message and figure out why an error is occurring
@@ -10,4 +12,9 @@ function capitalise(str) {
10
12
}
11
13
12
14
// =============> write your explanation here
13
-
// =============> write your new code here
15
+
// The error is occurring because the function is trying to declare a variable with the same name as the parameter, which is not allowed in JavaScript.
16
+
// The variable `str` is being redeclared inside the function, causing a syntax error.
0 commit comments