Skip to content

Conversation

@Shayida999
Copy link

@Shayida999 Shayida999 commented Nov 22, 2025

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

Questions

none for now. Thanks.

@github-actions
Copy link

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@Shayida999 Shayida999 added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 22, 2025
Copy link

@bp7968h bp7968h left a comment

Choose a reason for hiding this comment

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

Reviewed

Note: Do not have the access to change the label, have request, change tomorrow.

};

for (const value of author) {
for (const value of of Object.values(author)) {
Copy link

Choose a reason for hiding this comment

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

This works, however please note there are more cleaner ways to achieve this. Knowing those will definitely help in the future.

@@ -1,3 +1,20 @@
function contains() {}
function contains(obj, prop) {
Copy link

Choose a reason for hiding this comment

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

This fulfils the requirements, now think of the below:

  • What will happen if we inverse the if condition check.
  • What does hasOwnProperty method return, do we need explicit return statement

This will help make this more better and less cluttered!

for (let i = 0; i < pairs.length; i++){

const country = pairs[i][0];
const country = pairs[i][1];
Copy link

Choose a reason for hiding this comment

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

Maybe a typo here, country is a constant, can it be redeclared?


const country = pairs[i][0];
const country = pairs[i][1];
lookup[country] = currency;
Copy link

Choose a reason for hiding this comment

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

Does currency exist in the global and local scope?


for (let i = 0; i < pairs.length; i++){

const country = pairs[i][0];
Copy link

Choose a reason for hiding this comment

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

There is cleaner way de-structuring of accessing the values, if we expect the array to have fixed number of items,

for (let i = 0; i < keyValuePairs.length; i++){
const pair = keyValuePairs[i];
const indexOfEquals = pair.indexOf("=");
if(indexOfEquals === -1){
Copy link

Choose a reason for hiding this comment

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

Should we handle key with no value?

function tally() {}
function tally(array) {

if (!Array.isArray(arr)) {
Copy link

Choose a reason for hiding this comment

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

Maybe a typo, does arr exist?

Comment on lines +17 to +23
if (counts[item]) {

counts[item]= counts[item] + 1;
}
else {
counts[item]= 1;
}
Copy link

Choose a reason for hiding this comment

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

What if we start at 0 when the key is undefined and then increment by 1 if exists. Will shorten the code for sure.

// c) What does Object.entries return? Why is it needed in this program?
[["a", 1], ["b", 2]]

// d) Explain why the current return value is different from the target output
Copy link

Choose a reason for hiding this comment

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

This is asking why does the current invert function returns {key: 2} when { a: 1, b: 2 } is passed as argument. Shouldn't the function return {"1": "a", "2": "b"}?

const invertedObj = {};

for (const [key, value] of Object.entries(obj)) {
invertedObj.key = value;
Copy link

Choose a reason for hiding this comment

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

This will create key key in the object invertedObj, is that our goal (make key to value and value to key).

@bp7968h bp7968h added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants