Skip to content

Commit 51c8d93

Browse files
committed
working on lesson_07
1 parent e226598 commit 51c8d93

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

lesson_07/conditionals/src/lesson7.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { computeLexicographicDistance } from "./util.js";
77
* @return True if the age corresponds to a voting age and false otherwise.
88
*/
99
export function canVote(age: number): boolean {
10+
if (age >= 18) {
11+
return true;
12+
}
1013
return false;
1114
}
1215

@@ -18,10 +21,19 @@ export function canVote(age: number): boolean {
1821
* @return -1 if a is less than b, 1 if a is greater than b, and 0 otherwise.
1922
*/
2023
export function compareStrings(a: string, b: string): number {
24+
if (a > b) {
25+
return 1;
26+
}
27+
if (a < b) {
28+
return -1;
29+
}
30+
if (a=b) {
31+
return 0;
32+
}
2133
// The distance will be a number less than 0 if string `a` is lexicographically less than `b`, 1
2234
// if it is greater, and 0 if the strings are equal.
2335
const distance = computeLexicographicDistance(a, b);
24-
36+
2537
// TODO(you): Finish this method.
2638

2739
return 0;
@@ -47,6 +59,8 @@ export function convertGpaToLetterGrade(gpa: number): string {
4759
* @return The factorial of n.
4860
*/
4961
export function computeFactorial(n: number): number {
62+
let product=1
63+
for()
5064
return 0;
5165
}
5266

0 commit comments

Comments
 (0)