London | 26-ITP-May | Jorvan White | Sprint 2 | Coursework - #1418
London | 26-ITP-May | Jorvan White | Sprint 2 | Coursework #1418JorvanW wants to merge 23 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| console.log(`${recipe.title} | ||
| serves ${recipe.serves} | ||
| ingredients: | ||
| ${recipe.ingredients.join("\n")}`); |
| test("creates a country currency code lookup for multiple codes",() => { | ||
| expect(createLookup(countryCurrencyPairs)).toEqual([[US, 'USD'], [CA, 'CAD'], [EN, 'GBP']]); | ||
| }) |
There was a problem hiding this comment.
You could test one currency pair first, maybe something not included in this list, and then move into a bigger list. Having two tests with different inputs really helps prove that things aren't hardcoded in your solution.
|
|
||
| test.todo("creates a country currency code lookup for multiple codes"); | ||
| test("creates a country currency code lookup for multiple codes",() => { | ||
| expect(createLookup(countryCurrencyPairs)).toEqual([[US, 'USD'], [CA, 'CAD'], [EN, 'GBP']]); |
There was a problem hiding this comment.
Where is countryCurrencyPairs coming from? When I run this test it fails. Please take another look.
There was a problem hiding this comment.
updated both the test file and js file. Removed unnecessary sections.
| queryParams[key] = value; | ||
|
|
||
|
|
||
| console.log(pair) |
| // Then it should return an empty object | ||
| test.todo("tally on an empty array returns an empty object"); | ||
| test("tally on an empty array returns an empty object",() => { | ||
| expect(tally([])).toEqual([]); |
There was a problem hiding this comment.
Correction needed here, test asks for "return an empty object"
| function tally(array) { //(array) is the input to the function | ||
|
|
||
| if (!Array.isArray(array)){ //checking if array is actually an array | ||
| throw new Error("Input must be an array"); | ||
| } | ||
|
|
||
| if (array.length === 0){ //if array is empty return a empty array | ||
| return [] | ||
| } | ||
|
|
||
|
|
||
| const result = {} //creates result as an empty object which will store the counts | ||
|
|
||
|
|
||
| for (const item of array){ //'for' loops through every item in the array | ||
| if (result[item]){ // checks if the item is already in the result{} | ||
| result[item]++} // If it is then '++' tells it to add 1 to the value | ||
|
|
||
| else { | ||
| result[item] = 1; // else is saying that if it doesn't exist then we give it a value of 1 |
There was a problem hiding this comment.
I generally appreciate the comments adding clarity for future ref and readers, but it's not needed and maybe makes the committed code messy. This solution is fairly easy to interpret without it and we want clean commits as much as possible
| test("When invert is passed, keys and values in the object should be swapped ",() => { | ||
| expect({x : 10, y : 20}).toEqual({x : 10, y : 20}); | ||
| }); |
There was a problem hiding this comment.
Was this test suite abandoned when you saw the questions in the js file?
There was a problem hiding this comment.
this test suite is unfinished and not accurate to the goals of the function - see my last comment in the invert.js file
There was a problem hiding this comment.
fixed the function and added more test cases
|
|
||
|
|
||
| // c) What does Object.entries return? Why is it needed in this program? | ||
| // It returns an array of property into the object |
There was a problem hiding this comment.
This comment is clear - please rephrase.
What specifically does the method populate the array with?
why is it useful here?
| // The current return value only shows {key: 2}. It doesn't show the first key and value only the second, | ||
| // and it doesn't specify the second key. Its just defined as 'key'. |
There was a problem hiding this comment.
Missing a part here - yes it's only catching the final key,value pair, and yes it's specifically saying 'key', but anything else wrong about the output?
| // The current return value only shows {key: 2}. It doesn't show the first key and value only the second, | ||
| // and it doesn't specify the second key. Its just defined as 'key'. | ||
|
|
||
| // e) Fix the implementation of invert (and write tests to prove it's fixed!) |
There was a problem hiding this comment.
This part is missing - your current test suite doesn't correctly test the behaviour of invert - check the example given in the top comment above again. You also haven't built the test suite up - start with a small example and build up to a bigger object. Please amend
Poonam-raj
left a comment
There was a problem hiding this comment.
Some great work writing tests and implementing solutions - a few comments worth addressing, especially in the interpret section where testing is particularly lacking
…object as required
…test cases for invert
Self checklist
Changelist
Created Pull Request from Sprint 2 Coursework and updated for Pull Request