Skip to content

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

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

London | 26-ITP-May | Vitalii Kmit | Sprint 1 | Exercises#1458
Vitalii-code wants to merge 8 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
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?

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!

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.

Comment thread Sprint-1/implement/max.js
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

Comment thread Sprint-1/implement/sum.js
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)"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants