File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11// Predict and explain first...
22// =============> write your prediction here
3+ //Answer: I predict that there will be a Reference Error, because str get's re-declared with let
4+ //inside the function even though it already is declared as it is the parameter. Perhaps it would
5+ // be solved by removing the "let".
36
47// call the function capitalise with a string input
58// interpret the error message and figure out why an error is occurring
69
10+ /*
711function capitalise(str) {
812 let str = `${str[0].toUpperCase()}${str.slice(1)}`;
913 return str;
1014}
1115
16+ console.log(capitalise("hellllo");
17+ */
18+
1219// =============> write your explanation here
20+ // Answer: I got a Syntax Error, Identifier 'str' has already been declared. So 'str' needs to not
21+ // be declared again. I will try to write the code without the let
1322// =============> write your new code here
23+
24+ function capitalise ( str ) {
25+ str = `${ str [ 0 ] . toUpperCase ( ) } ${ str . slice ( 1 ) } ` ;
26+ return str ;
27+ }
28+ console . log ( capitalise ( "hellllo" ) ) ;
You can’t perform that action at this time.
0 commit comments