generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 155
Glasgow | May-2025 | Mansoor Munawar | Data Groups| Sprint 2 #753
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
MansoorM11
wants to merge
9
commits into
CodeYourFuture:main
Choose a base branch
from
MansoorM11: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.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9fd1ab0
Explained why there is bug in the program and also fixed it
MansoorM11 e622cb5
fixed the bug in the program and explained why it occurs.
MansoorM11 ce0ebff
fixed the bug in the code and explained the reason for it
MansoorM11 c0879fa
implemented a function "contains" based on specific requirements and …
MansoorM11 2bc5d13
created an additional test for contains function
MansoorM11 f3af6ca
created 'createLoopup' function based on the requirements and also cr…
MansoorM11 91c79c8
fixed my querystring function to take into account more edge cases an…
MansoorM11 9b981b8
created function "tally" based on the requirement and also created te…
MansoorM11 3933f76
fixed the invert function and explained why previously it didnt work …
MansoorM11 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,6 @@ | ||
function contains() {} | ||
function contains(obj, key) { | ||
return Object.hasOwn(obj, key); | ||
} | ||
|
||
console.log(contains([1, 2, 3, 4], "ingredients")); | ||
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,15 @@ | ||
function createLookup() { | ||
function createLookup(twoDeminsionalArray) { | ||
// implementation here | ||
let result = {}; | ||
for (let [country, currency] of twoDeminsionalArray) { | ||
result[country] = currency; | ||
} | ||
return result; | ||
} | ||
|
||
console.log( | ||
createLookup([ | ||
["US", "USD"], | ||
["CA", "CAD"], | ||
]) | ||
); | ||
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,17 @@ | ||
function tally() {} | ||
function tally(arrayOfItems) { | ||
if (!Array.isArray(arrayOfItems)) { | ||
throw new TypeError("parameter must be an array"); | ||
} | ||
let result = {}; | ||
arrayOfItems.forEach((element) => { | ||
if (element in result) { | ||
result[element] += 1; | ||
} else { | ||
result[element] = 1; | ||
} | ||
}); | ||
return result; | ||
} | ||
console.log(tally([])); | ||
|
||
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,13 @@ | ||
const invert = require("./invert.js"); | ||
|
||
test("When invert is passed an object it should swap the keys and values in the object and then return it", () => { | ||
let currentOutput = invert({ x: 10, y: 20 }); | ||
let targetOutput = { 10: "x", 20: "y" }; | ||
expect(currentOutput).toEqual(targetOutput); | ||
}); | ||
|
||
test("When invert is passed an object it should swap the keys and values in the object and then return it", () => { | ||
let currentOutput = invert({ a: 1, b: 2 }); | ||
let targetOutput = { 1: "a", 2: "b" }; | ||
expect(currentOutput).toEqual(targetOutput); | ||
}); |
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.
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 happens if you pass it some input like contains([1,2,3,4], "length") - remember one of your test specifications says it should give false when passed an array