generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
London|MAY_2025|FATMA_DEGIRMENCI|STRUCTRING_AND_TESTING_DATA| SPRINT 3 #640
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
fatmaevin
wants to merge
18
commits into
CodeYourFuture:main
Choose a base branch
from
fatmaevin:coursework/sprint-3
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 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
32bfe6b
Add getAngleType function with test cases
04ef167
Implement isProperFraction function with full test coverage
85d846d
Implement getCardValue function with tests for number, face, ace, and…
90b9b78
Add Jest test for getAngleType function
486f3ff
Add Jest tests for isProperFraction function
fd4408c
Add Jest test cases getCardValue for function
5d5710c
Implement countChar function and add Jest test for no occurrences
c85b269
Implement getOrdinalNumber function and write tests covering special …
4d42edc
Implement repeat function and add tests for required cases
5385330
Implement a function and add test
731317d
Implement a function according to instructions
c812738
Understand the function and and answer the questions
998c58b
Install the package
b641fbc
Handle invalid angle values in getAngleType and add tests
382aba7
Add isProperFraction function with zero checks and tests
e127aff
Add regex to support numeric formats in card ranks and improve tests …
073b7b2
Refactor tests by categories and fix function to handle numbers endin…
0e8164a
Add previousPasswords parameter; improve tests for false cases
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,18 +1,15 @@ | ||
function getAngleType(angle) { | ||
if (angle === 90) return "Right angle"; | ||
// replace with your completed function from key-implement | ||
|
||
if (angle === 90) { | ||
return "Right angle"; | ||
} else if (angle < 90) { | ||
return "Acute angle"; | ||
} else if (angle > 90 && angle < 180) { | ||
return "Obtuse angle"; | ||
} else if (angle === 180) { | ||
return "Straight angle"; | ||
} else if (angle > 180 && angle < 360) { | ||
return "Reflex angle"; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
// Don't get bogged down in this detail | ||
// Jest uses CommonJS module syntax by default as it's quite old | ||
// We will upgrade our approach to ES6 modules in the next course module, so for now | ||
// we have just written the CommonJS module.exports syntax for you | ||
module.exports = getAngleType; | ||
module.exports = getAngleType; |
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,6 +1,10 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
if (denominator === 0) { | ||
return undefined; | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else if (Math.abs(numerator) < Math.abs(denominator)) { | ||
return true; | ||
} else { | ||
return false; | ||
} | ||
} | ||
|
||
module.exports = isProperFraction; | ||
module.exports = isProperFraction; |
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,13 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
const rank = card.slice(0, -1); | ||
if (Number(rank) <= 10 && Number(rank) >= 2) { | ||
return Number(rank); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} else if (rank === "A") { | ||
return 11; | ||
} else if (rank === "Q" || rank === "K" || rank === "J") { | ||
return 10; | ||
} else { | ||
throw new Error("Invalid card rank"); | ||
} | ||
} | ||
module.exports = getCardValue; | ||
module.exports = getCardValue; |
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,11 +1,17 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 4 for 4 of Hearts", () => { | ||
expect(getCardValue("4♠")).toEqual(4); | ||
}); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
test("should return 10 for Queen of Spades", () => { | ||
expect(getCardValue("Q♠")).toEqual(10); | ||
}); | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
// Case 4: Handle Ace (A): | ||
// Case 5: Handle Invalid Cards: | ||
expect(getCardValue("A♠")).toEqual(11); | ||
}); | ||
|
||
test("should throw error for invalid card", () => { | ||
expect(() => getCardValue("Z♠")).toThrow("Invalid card rank"); | ||
}); |
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,11 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
let count = 0; | ||
for (let i = 0; i <= stringOfCharacters.length; i++) { | ||
if (stringOfCharacters[i] === findCharacter) { | ||
count = count + 1; | ||
} | ||
} | ||
return count; | ||
} | ||
|
||
module.exports = countChar; | ||
module.exports = countChar; |
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
18 changes: 14 additions & 4 deletions
18
Sprint-3/3-mandatory-practice/implement/get-ordinal-number.js
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 getOrdinalNumber(num) { | ||
return "1st"; | ||
} | ||
const getOrdinalNumber = (n) => { | ||
if (n > 3 && n < 21) return n + "th"; | ||
switch (n % 10) { | ||
case 1: | ||
return n + "st"; | ||
case 2: | ||
return n + "nd"; | ||
case 3: | ||
return n + "rd"; | ||
default: | ||
return n + "th"; | ||
} | ||
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}; | ||
|
||
module.exports = getOrdinalNumber; | ||
module.exports = getOrdinalNumber; |
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,11 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(str, count) { | ||
if (count < 0) { | ||
throw new Error("count must be a non-negative integer"); | ||
} else if (count === 0) { | ||
return ""; | ||
} else if (count > 0) { | ||
return str.repeat(count); | ||
} | ||
} | ||
|
||
module.exports = repeat; | ||
module.exports = repeat; |
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.