Skip to content

Commit 100b9fd

Browse files
reset to origin file Sprint-2/1-key-errors/0.js
1 parent 65e1a8e commit 100b9fd

File tree

1 file changed

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

1 file changed

+2
-10
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
// Predict and explain first...
22
// =============> write your prediction here
3-
//the function will turn the first given string into Uppercase.
43

54
// call the function capitalise with a string input
65
// interpret the error message and figure out why an error is occurring
76

87
function capitalise(str) {
9-
let strWithUpperCase = `${str[0].toUpperCase()}${str.slice(1)}`;
10-
return strWithUpperCase;
8+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9+
return str;
1110
}
1211

1312
// =============> write your explanation here
14-
// str[0].toUpperCase() ---> gets the first character and uses build-in method to convert a char to uppercase
15-
// str.slice(1) ----> will slice the array or sting "start from 1" to the rest of array or string
16-
// we get an error because we "re-declare" the str variable as parameter and as call back of expression
17-
1813
// =============> write your new code here
19-
20-
const myStr = "i forgot add this string";
21-
console.log(capitalise(myStr));

0 commit comments

Comments
 (0)