Skip to content

London |ITP-Jan-2016 | Ping Wang | Sprint 2 |Coursework#1023

Open
pathywang wants to merge 7 commits intoCodeYourFuture:mainfrom
pathywang:sprint-2
Open

London |ITP-Jan-2016 | Ping Wang | Sprint 2 |Coursework#1023
pathywang wants to merge 7 commits intoCodeYourFuture:mainfrom
pathywang:sprint-2

Conversation

@pathywang
Copy link

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

i did coursework with node or npm jest to check my work to make sure that my code works as expected after i completed my prep

@pathywang pathywang added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 17, 2026
Comment on lines +17 to +19
for (const ingredient of recipe.ingredients) {
console.log(ingredient);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This work.

Alternate approach to explore:
Since ingredient values are separated by '\n' in the output, we could also use Array.prototype.join() to construct the equivalent string and then output the resulting string.

Comment on lines +38 to +49
object={name:'jin', age:13}
console.log (contains(object, 'nice'))
test.todo("contains no nice property in object return false")



// Given invalid parameters like an array
// When passed to contains
// Then it should return false or throw an error
object={name:'jin', age:13}
console.log (contains(object, '[1,2,5]'))
test.todo("contains no array property in object return false")
Copy link
Contributor

@cjyuan cjyuan Mar 21, 2026

Choose a reason for hiding this comment

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

test.todo(" ... ") is just a placeholder to serve as a reminder for "what needs to be done". You were supposed to implement the corresponding Jest tests described in the comments on this file.

Can you implement all the tests in all the .test.js files?

Comment on lines +1 to 8
function createLookup(countryCurrencyPairs) {
const countryCodeCurrency={}
for (const[country, currency] of countryCurrencyPairs){
countryCodeCurrency[country]=currency
}

return countryCodeCurrency
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The spacing around the operators is not quite consistent.

Have you installed the prettier VSCode extension and enabled "Format on save/paste" on VSCode,
as recommended in
https://github.com/CodeYourFuture/Module-Structuring-and-Testing-Data/blob/main/readme.md
?

Comment on lines +40 to +46
const result1=createLookup([['GB','GBP']])
console.log(result1)
test.todo('creates a single county code currency ')

//given an empty country currency pair/array
console.log(createLookup([[]]))
test.todo('return an empty object with empty pair given') No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Should also implement these tests

  • Better practice to end each statement by a semicolon (;) to reduce chance of errors.

Comment on lines +20 to +22
console.log(parseQueryString("color=blue&quality=good"))
console.log(parseQueryString("equation=x=y+1"))
console.log(parseQueryString(""))
Copy link
Contributor

Choose a reason for hiding this comment

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

For each of the following function calls, does your function return the value you expect?

parseQueryString("a=b&=&c=d")
parseQueryString("a=b&&c=d")

Note:

  • (Implementing this is optional) In real query string, both key and value are percent-encoded or URL encoded in the URL.
    For example, the string "5%" is encoded as "5%25". So to get the actual value of "5%25"
    (whether it is a key or value in the query string), we need to call a function to decode it.

  • You can also explore the URLSearchParams API.

Comment on lines +2 to +16
if (!Array.isArray(array)) {
throw new Error("Invalid input: expected an array");
}

const count={}
for(item of array){
if (count[item]){
count[item] += 1
}
else{
count[item] = 1
}
}
return count
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  • Can you improve the indentation?

  • Does the following function call returns the value you expect?

tally(["toString", "toString"]);

Suggestion: Look up an approach to create an empty object with no inherited properties.

@cjyuan cjyuan 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 Mar 21, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants