Repository navigation
Manchester | 26-ITP-Sept | Aklilu Mihtsun | Sprint 2 | Coursework/sprint 2 #1514
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
Open
AkliluMihtsun
wants to merge
22
commits into
CodeYourFuture:main
Choose a base branch
from
AkliluMihtsun:coursework/Sprint-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+514
−124
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
caa5bb0
Fix address object property access to log house number correctly
AkliluMihtsun e2397d8
Fix for loop to correctly iterate over object properties in author.js
AkliluMihtsun df238c9
Fix recipe.js to correctly log ingredients and improve comments
AkliluMihtsun 345b355
Add tests for contains function to validate object property checks an…
AkliluMihtsun 2ae7312
Implement contains function to check for property existence in an object
AkliluMihtsun fd4f6f5
Add jsconfig.json and update package.json for Jest type definitions
AkliluMihtsun a5c908d
Remove unnecessary TypeScript reference from contains.test.js
AkliluMihtsun 3a2f213
Refactor tests in lookup.test.js to validate createLookup function be…
AkliluMihtsun 4563f09
Implement createLookup function to transform country-currency pairs i…
AkliluMihtsun 64405b5
Implement tally function to count occurrences of items in an array
AkliluMihtsun c4e3c36
Refactor tally tests to improve clarity and coverage
AkliluMihtsun 6a4db13
Refactor parseQueryString function to improve query parameter handlin…
AkliluMihtsun 7aae036
Fix syntax error in querystring.test.js by adding missing semicolon
AkliluMihtsun dc40ffc
Fix invert function implementation to correctly swap keys and values …
AkliluMihtsun 2ebc9d0
Add tests for invert function to verify key-value inversion
AkliluMihtsun 69d91ee
Fix author.js to correctly log property values instead of keys
AkliluMihtsun 7ee7105
Refactor contains function to use Object.hasOwn for property checking
AkliluMihtsun 30f8403
Refactor recipe.js to log ingredients in a single console statement
AkliluMihtsun 1d3281e
Refactor createLookup function to improve input validation and error …
AkliluMihtsun 32d1314
Refactor tests in lookup.test.js for clarity and accuracy in error me…
AkliluMihtsun fba5a72
Update test descriptions in tally.test.js for clarity and accuracy
AkliluMihtsun fae8185
Fix variable declaration in tally function to use const for objectItem
AkliluMihtsun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| function contains() {} | ||
|
|
||
| function contains(object, name) { | ||
| if (typeof object !== "object" || Array.isArray(object) || object === null) { | ||
| throw new Error("contains requires an object"); | ||
| } | ||
| // the in Checks own and inherited properties so that is why it returned true when the name is 'toString' | ||
| return Object.hasOwn(object, name); | ||
| } | ||
| //console.log(contains({ a: 1 }, "toString")); | ||
| module.exports = contains; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,22 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(countryCurrencyPairs) { | ||
| if (!Array.isArray(countryCurrencyPairs)) { | ||
| throw new Error("createLookup requires an array"); | ||
| } | ||
| for (const keyVlauePairs of countryCurrencyPairs) { | ||
| if (!Array.isArray(keyVlauePairs)) { | ||
| throw new Error("createLookup requires an array of key value pair"); | ||
| } else if (keyVlauePairs.length !== 2) { | ||
| throw new Error("createLookup requires key value pair"); | ||
| } else if (keyVlauePairs.some((element) => typeof element !== "string")) { | ||
| throw new Error("createLookup requires a string of key value pair"); | ||
| } | ||
| } | ||
|
|
||
| let currencyObject = {}; | ||
| for (const arrayCurrency of countryCurrencyPairs) { | ||
| currencyObject[arrayCurrency[0]] = arrayCurrency[1]; | ||
| } | ||
| return currencyObject; | ||
| } | ||
|
|
||
| module.exports = createLookup; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,16 @@ | ||
| function tally() {} | ||
| function tally(array) { | ||
| if (!Array.isArray(array)) { | ||
| throw new Error("tally requires an array"); | ||
| } | ||
| const objectItem = {}; | ||
| for (const item of array) { | ||
| if (objectItem[item]) { | ||
| objectItem[item] = objectItem[item] + 1; | ||
| } else { | ||
| objectItem[item] = 1; | ||
| } | ||
| } | ||
| return objectItem; | ||
| } | ||
|
|
||
| module.exports = tally; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| const invert = require("./invert.js"); | ||
|
|
||
| test("checking inversion ", () => { | ||
| expect(invert({ x: 10, y: 20 })).toEqual({ 10: "x", 20: "y" }); | ||
| expect(invert({ f: 34, h: 45, j: "rf" })).toEqual({ | ||
| 34: "f", | ||
| 45: "h", | ||
| rf: "j", | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "types": ["jest"] | ||
| }, | ||
| "exclude": ["node_modules"] | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.