Skip to content

Commit 10df15c

Browse files
committed
feat:add unfinished lesson_7 work
1 parent d7b5c6b commit 10df15c

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

lesson_07/conditionals/src/lesson7.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ export function compareStrings(a: string, b: string): number {
1212
// if it is greater, and 0 if the strings are equal.
1313
const distance = computeLexicographicDistance(a, b);
1414

15+
if (distance < 0) {
16+
return -1;
17+
} else if (distance > 0) {
18+
return 1;
19+
}
1520
// TODO(you): Finish this method.
16-
1721
return 0;
1822
}
1923

lesson_07/conditionals/src/part_e.ts

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,39 @@
66
* @returns
77
*/
88
export function isUppercase(char: string): boolean {
9+
const lower: string[] = [
10+
"A",
11+
"B",
12+
"C",
13+
"D",
14+
"E",
15+
"F",
16+
"G",
17+
"H",
18+
"I",
19+
"J",
20+
"K",
21+
"L",
22+
"M",
23+
"N",
24+
"O",
25+
"P",
26+
"Q",
27+
"R",
28+
"S",
29+
"T",
30+
"U",
31+
"V",
32+
"W",
33+
"X",
34+
"Y",
35+
"Z",
36+
];
37+
for (const letter of lower) {
38+
if (char === letter) {
39+
return true;
40+
}
41+
}
942
return false;
1043
}
1144

@@ -17,7 +50,11 @@ export function isUppercase(char: string): boolean {
1750
* @returns
1851
*/
1952
export function canGetDriverLicense(age: number, passedTest: boolean): boolean {
20-
return false;
53+
if (age >= 18 && passedTest === true) {
54+
return true;
55+
} else {
56+
return false;
57+
}
2158
}
2259

2360
/**
@@ -29,5 +66,9 @@ export function canGetDriverLicense(age: number, passedTest: boolean): boolean {
2966
* @returns
3067
*/
3168
export function isStoreOpen(day: string, hour: number): boolean {
32-
return false;
69+
if (day !== "Sunday" && hour < 21 && hour >= 9) {
70+
return true;
71+
} else {
72+
return false;
73+
}
3374
}

0 commit comments

Comments
 (0)