generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 210
Karla Grajales | Sprint-2 - Module-Data-Groups | SPRINT 2 #291
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
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f2d10ad
accesing to property address object function
Grajales-K da1dc5f
Iterate over the object's keys and log their values
Grajales-K c27d44e
Accessing the houseNumber property from the address object
Grajales-K 8aedc32
updated commets
Grajales-K ff07f10
updated commets
Grajales-K c21f8e3
added functions and test for contains file
Grajales-K c4a929b
added test for lookup
Grajales-K 87347a5
test and fuction for querystring
Grajales-K 08760af
added test for tally.test.js
Grajales-K 0725635
added test for invert function
Grajales-K dfa4be4
refactor fucntion with join method
Grajales-K e256d82
added validation for string encoded using percent-encoding
Grajales-K 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,5 @@ function calculateMedian(list) { | |
| } | ||
|
|
||
| module.exports = calculateMedian; | ||
|
|
||
|
|
||
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,14 @@ | ||
| function contains() {} | ||
| function contains(obj, property) { | ||
| // check if it is an Array | ||
| if (typeof obj !== "object" || obj === null || Array.isArray(obj) || obj === undefined ) { | ||
| return false; | ||
| } | ||
| for (let key in obj) { | ||
| if (key === property) { | ||
| return true; | ||
| } | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| 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,24 @@ | ||
| function createLookup() { | ||
| // implementation here | ||
| function createLookup(input) { | ||
| const objInput = {}; | ||
|
|
||
| // Validate input is an array of arrays | ||
| if (!Array.isArray(input)) { | ||
| throw new Error("Input must be an array of arrays."); | ||
| } | ||
|
|
||
| // Populate the object | ||
| for (const pair of input) { | ||
| if (!Array.isArray(pair) || pair.length !== 2) { | ||
| throw new Error( | ||
| "Each element of the input array must be a key-value pair." | ||
| ); | ||
| } | ||
|
|
||
| const [key, value] = pair; | ||
| objInput[key] = value; | ||
| } | ||
|
|
||
| return objInput; | ||
| } | ||
|
|
||
| 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,23 @@ | ||
| function tally() {} | ||
| function tally(array) { | ||
| // check if input is an array | ||
| if (!Array.isArray(array)) { | ||
| return { error: "Input must be an array" }; | ||
| } | ||
|
|
||
| // create an empty object to store counts | ||
| let counts = {}; | ||
|
|
||
| // Loop through the array and count items | ||
| for (let item of array) { | ||
| if (counts[item]) { | ||
| //the loop checks if the current item already exists as a key in the counts object. | ||
| counts[item] += 1; // Increase count if item exists | ||
| } else { | ||
| counts[item] = 1; //Initialize count if item is new | ||
| } | ||
| } | ||
|
|
||
| return counts; | ||
| } | ||
|
|
||
| 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
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.