Skip to content

Shadi A.#3

Open
shmoonwalker wants to merge 6 commits intoHackYourAssignment:mainfrom
shmoonwalker:main
Open

Shadi A.#3
shmoonwalker wants to merge 6 commits intoHackYourAssignment:mainfrom
shmoonwalker:main

Conversation

@shmoonwalker
Copy link

Complete All Tasks For Week 5

Copy link

@reposman33 reposman33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few remarks about using Array methods instead of for loops.

let count = 0;

for (let i = 0; i < numbers.length; i++) {
if (numbers[i] > threshold) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use Array methods the same code can be written like this:

count = numbers.filter(num > num > threshold).length.

I'm not sure if Array prototype methods are already known at this stage of the course but it is definitely preferred over the traditional loop construct

};


console.log(`There is ${countNumbersInArray([90,45,76,3,5,8,2,77,3,65,43,4,45,90], 40)} numbers above the threshold.`);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just nitpicking here - "numbers above the threshold" => "numbers above 40"

text[i] === "a" ||
text[i] === "e" ||
text[i] === "i" ||
text[i] === "o" ||

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an easier way - use the include Array method:

if (["a", "e", "i", "o", "u"].includes(text[i])) {}

Ah, I see that in Week 4 - Data structures and loops this is not covered so consider Array methods a bonus https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array.

console.time("Linear Search");
linearSearch(bigArray, 999999);
console.timeEnd("Linear Search");
const bigArray = sizes.map(size => generateBigArray(size));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@reposman33 reposman33 added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed Review in progress labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants