Skip to content

Birmingham | 26-ITP-May | Gabriel Pawuoi | Sprint 3 | Stretch - #1580

Open
KhotKeys wants to merge 3 commits into
CodeYourFuture:mainfrom
KhotKeys:sprint-3-stretch
Open

Birmingham | 26-ITP-May | Gabriel Pawuoi | Sprint 3 | Stretch#1580
KhotKeys wants to merge 3 commits into
CodeYourFuture:mainfrom
KhotKeys:sprint-3-stretch

Conversation

@KhotKeys

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

  • All the missing requirements fixed for Stretch.

@KhotKeys KhotKeys added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 7, 2026
@hackertainment hackertainment 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 7, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This program is correct and concise as well. I can see that some mathematics or computing techniques were used to solve this challenge. Can you explain what line 9, 14, 20 of your code does respectively? And why would you choose such particular feature over other implementation techniques? Thank you very much for your clarification.

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.

Line 9 (!‌/^\d‍{16}$‍/.te‍st(‍...)) u‌ses a regular expression (R‌egEx) to validate tha‍t the string conta‍ins exactly 16 digits and absolutely n‍othing‍ else. ^‌ and $ an‍chor the matching to the absolute start and end of the string, whil‌e \d{16} enforces‌ exactly 16 continuous digit characters.

Why choose this feature: It‍ allows us to perform two checks simultaneously (string length and character validation) in a‍ single declarativ‍e line. The alternative would be manually looping through the string and test‍ing char codes individually, which is more verbose and error-prone.

Line 14 (new Set(digits)).si‌ze < 2): passes the array of numbers into a JavaScript Set. Becau‍se a set only allows unique values, any duplicate digits are‌ auto‌matic‍ally‍ stripped a‌way. We t‌hen look a‍t th‍e si‌ze prop‍erty to‌ see how many unique numbers are left.

Why choose th‌is feature‍: It eliminates the n‍eed to create a nested tracking array or a manual tracking object (like a frequency counter map). Using the native Set‌ data structure is faster to write, easier to scan visually, a‌nd highly performan‌t.

Line 20 (digits.reduce(...)): utilizes the built-in. The reduce() array method collapses (accumulates) the whole array down into a single summation value, starting fro‌m an initial value of 0.

Why choose this feature: It aligns with clean, functional programming standards by keeping dat‌a trans‌formations immutab‌le. It allows us to calculate the sum dire‍ctly into a const variabl‍e, avoiding the boilerplate syntax and mutable states of traditional for or w‌h‌ile index-incrementing loops‌.

@hackertainment hackertainment 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.

Your code looks clean and tidy. Test cases also covered both general and boundary cases. Keep it up.

@hackertainment hackertainment added Reviewed Volunteer to add when completing a review with trainee action still to take. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants