-
-
Notifications
You must be signed in to change notification settings - Fork 96
London | Nadarajah_Sripathmanathan | Sprint-2 | Week3 #466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Dear admin , I have done step 3 sprint -2 . could you review please |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great. Feel free to mark this as "Complete" anytime.
function createLookup(items, keySelector, valueSelector) { | ||
if (!Array.isArray(items)) { | ||
return {}; | ||
} | ||
|
||
if (typeof keySelector !== 'function' || typeof valueSelector !== 'function') { | ||
throw new Error('keySelector and valueSelector must be functions'); | ||
} | ||
|
||
const lookup = {}; | ||
|
||
for (const item of items) { | ||
const key = keySelector(item); | ||
const value = valueSelector(item); | ||
|
||
if (key !== undefined) { | ||
lookup[key] = value; | ||
} | ||
} | ||
|
||
return lookup; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Why not just accept two strings as the 2nd and 3rd parameters and write lines 14-15 as
const key = item[keySelector]
const value = item[valueSelector]
?
const decodedKey = decodeURIComponent(key.replace(/\+/g, " ")); | ||
|
||
// Decode value, but do not replace "+" with spaces | ||
const decodedValue = value ? decodeURIComponent(value) : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's your rationale behind not treating +
in the value as space?
Can you fix this branch so that it does not contain any modified files in the Sprint-1 folder? |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.