Conversation
YanaP1312
commented
Feb 9, 2026
- Added countAboveThreshold function;
- Added unit tests for calculateAverage function;
- Fixed bug with VSCode debugger;
- Added comparison linear and binary searching.
| @@ -1 +1,21 @@ | |||
| //Your code here | |||
| function countAboveThreshold(numbers, threshold) { | |||
| let totalAboveNumbers = 0; | |||
There was a problem hiding this comment.
let totalNumbersAboveThreshold :)))
There was a problem hiding this comment.
Good point! I renamed the variable to totalNumbersAboveThreshold to make it clearer. Thanks!))
|
|
||
| // option 2 | ||
| // function countAboveThreshold(numbers, threshold) { | ||
| // return numbers.filter((number) => number > threshold).length; |
|
|
||
| // option 3 | ||
| // function countAboveThreshold(numbers, threshold) { | ||
| // return numbers.reduce((sum, number) => sum + (number > threshold), 0); |
| @@ -1,17 +1,38 @@ | |||
| function countVowels(text) { | |||
| let count = 0; | |||
| const textFix = text.toLowerCase(); | |||
There was a problem hiding this comment.
I would do this toLowerCase() on each character within the loop because it is more precise - you only do toLowerCase() on the character you want to test, not on the whole text
There was a problem hiding this comment.
Thanks! I updated the function so that toLowerCase() is applied only to the current character inside the loop. The new version is pushed.
|
|
||
| //linearSearch | ||
| console.time("Linear Search 1k"); | ||
| linearSearch(generateBigArray(1000), 876); |
There was a problem hiding this comment.
generateBigArray(1000) should not be part of the console.time)... because now you measure 2 things: the time to generate a big array plus the time to search through the big array
There was a problem hiding this comment.
Thanks for the feedback! I moved generateBigArray() outside of console.time() so the timer now measures only the search operation, not the array creation.
|
|
||
| console.time("Linear Search 100k"); | ||
| linearSearch(generateBigArray(100000), 98345); | ||
| console.timeEnd("Linear Search 100k"); |
There was a problem hiding this comment.
this only outputs a number... it is nice to see something like 'searching for number 98345 in an array of 100000 took xxxx mseconds'
There was a problem hiding this comment.
I updated the labels in console.time() so the output now shows a descriptive message like “Searching for Х in array of Y: Zms”. This makes the results clearer and easier to read.
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |