@@ -74,10 +74,7 @@ export function myGrade(grade: number): string {
74
74
return gpa ;
75
75
}
76
76
77
- //I followed the same logic as question 2. I can already tell that
78
- // there may be many simpler ways to build this function. I am just
79
- // happy it came out with no errors and will make a note to play around
80
- // with this and see if I can't get it to look better (simpler/cleaner).
77
+ //I followed the same logic as question 2.
81
78
82
79
export function convertGpaToLetterGrade ( gpa : number ) : string {
83
80
if ( gpa >= 4.0 ) {
@@ -107,7 +104,7 @@ export function convertGpaToLetterGrade(gpa: number): string {
107
104
}
108
105
}
109
106
110
- const grade = convertGpaToLetterGrade ( 32 ) ;
107
+ const grade = convertGpaToLetterGrade ( 3.2 ) ;
111
108
console . log ( grade ) ;
112
109
113
110
/** (Q4)
@@ -166,7 +163,7 @@ export function getFirstNFibonacciNumbers(n: number): number[] {
166
163
myArray . push ( 1 , 1 ) ;
167
164
168
165
for ( let i = 2 ; i < n ; i ++ ) {
169
- //initialization(stats at 2 because I added the first two numbers in the sequence above)
166
+ //initialization(starts at 2 because I added the first two numbers in the sequence above)
170
167
// so this tells the function to start computing from the 3rd number. Condition: this tells
171
168
// the function that it can only work with numbers less than the given number.
172
169
// Increment: this tells the function to move on to the next number by 1 (no infinite loops).
@@ -208,3 +205,6 @@ export function binarySearch(
208
205
return binarySearch ( values , pivotIndex + 1 , end , value ) ;
209
206
}
210
207
// This problem was much easier to write out because of question 6.
208
+ const values = [ 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 ] ;
209
+ const index = binarySearch ( values , 4 , 8 , 14 ) ;
210
+ console . log ( index ) ;
0 commit comments