Skip to content

Commit 0a5221c

Browse files
committed
Working on Coursework Sprint 2: 1-key-errors, first problem
1 parent 3372770 commit 0a5221c

File tree

6 files changed

+31
-6
lines changed

6 files changed

+31
-6
lines changed

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

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
// Predict and explain first...
2-
// =============> write your prediction here
2+
// =============> This will not run because the variable str has already been used
3+
// as a parameter. This will cause a syntax error
4+
35

46
// call the function capitalise with a string input
57
// interpret the error message and figure out why an error is occurring
68

79
function capitalise(str) {
8-
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
9-
return str;
10-
}
10+
let str = `${str[0].toUpperCase()}${str.slice(1)}`;
11+
return str;
12+
}
1113

12-
// =============> write your explanation here
13-
// =============> write your new code here
14+
// =============> The first mistake this renders is indeed in line 14 that
15+
// "Identifier 'str' has already been declared"
16+
// =============>
17+
//
18+
function capitalise(str) {
19+
return `${str[0].toUpperCase()}${str.slice(1)}`;
20+
}
14.7 KB
Binary file not shown.
17.8 KB
Binary file not shown.

Sprint-2/Project-CLI-Treasure-Hunt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 4374e4e6b862b0a110e806b6115f3f6b3c22b26a

Sprint-2/huddle260216.png

24 KB
Loading

Sprint-2/prep.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function formatAs12HourClock(time) {
2+
return `${time} am`;
3+
}
4+
5+
const currentOutput = formatAs12HourClock("08:00");
6+
const targetOutput = "08:00 am";
7+
console.assert(
8+
currentOutput === targetOutput,
9+
`current output: ${currentOutput}, target output: ${targetOutput}`
10+
);
11+
12+
const currentOutput = formatAs12HourClock("23:00");
13+
const targetOutput = "11:00 pm";
14+
console.assert(
15+
currentOutput === targetOutput,
16+
`current output: ${currentOutput}, target output: ${targetOutput}`
17+
);

0 commit comments

Comments
 (0)