Skip to content

London | 26-ITP-May | Vitalii Kmit | Sprint 1 | Exercises - #1458

Open
Vitalii-code wants to merge 11 commits into
CodeYourFuture:mainfrom
Vitalii-code:sprint-1
Open

London | 26-ITP-May | Vitalii Kmit | Sprint 1 | Exercises#1458
Vitalii-code wants to merge 11 commits into
CodeYourFuture:mainfrom
Vitalii-code:sprint-1

Conversation

@Vitalii-code

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Work on sprint one exercises

@Vitalii-code Vitalii-code added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 22, 2026
@Khantdotcom Khantdotcom added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 24, 2026

@Khantdotcom Khantdotcom left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • Fix median logic
  • Look up what if you don't declare "const" in "for loop"
  • Improved data structure of dedupe(list)

Comment thread Sprint-1/fix/median.js Outdated
list = list.filter((item) => typeof item === "number");
list.sort((a, b) => a - b);

if (list.length <= 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If an array has exactly one number (e.g., [5]), what is the median?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It returns null because of the length check. But I think It should return 5 in case of passing [5]

Comment on lines +4 to +5
// for (let index = 0; index < list.length; index++) {
for (const element of list) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good job noticing a better approach for looping!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks

Comment on lines +1 to +13
function dedupe(list) {
const seen = {};
const result = [];

for (const item of list) {
if (seen[item] === undefined) {
seen[item] = true;
result.push(item);
}
}

return result;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good practice but there's a better data structure than simple dict and array. Check out this article here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah using sets here makes more sense

Comment thread Sprint-1/implement/max.js Outdated
function findMax(elements) {
let max = -Infinity;

for (i of elements) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can you look up what happens you don't declare "const" in for loop in javascript? Hint : related to "scope" of code blocks

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah it can update a variable called i outside of the scope which can cause issues

Comment thread Sprint-1/implement/sum.js Outdated
function sum(elements) {
let sum = 0;

for (i of elements) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The program can run but why do we need "for (const i of elements)"?

@Vitalii-code Vitalii-code added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Aug 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants