generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
London|May 2025|Alexandru Pocovnicu|Coursework/sprint 3 #639
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
alexandru-pocovnicu
wants to merge
31
commits into
CodeYourFuture:main
Choose a base branch
from
alexandru-pocovnicu: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 all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
301ccc0
d
alexandru-pocovnicu aee8b64
i have written the test and completed the code accordingly
alexandru-pocovnicu 76d10a5
created the tests and added new lines of code
alexandru-pocovnicu ae4f944
wrote assertions and completed the code accordingly
alexandru-pocovnicu e282ccf
replaced the comments with jest test cases
alexandru-pocovnicu d81fcbb
added the completed function
alexandru-pocovnicu 777b1e7
CREATED TEST CASES FOR THE FUNCTION
alexandru-pocovnicu 9dcbdca
replaced code with mine
alexandru-pocovnicu 02ba073
written all the test cases, all passed
alexandru-pocovnicu 7aab1ad
replaced with my code
alexandru-pocovnicu 5eb2d42
wrote the second test
alexandru-pocovnicu 743ea0a
updated the code
alexandru-pocovnicu cabdf43
implemented and tested additional cases
alexandru-pocovnicu 5889529
updated the code to cover the test cases
alexandru-pocovnicu 244fe2e
wrote the test cases
alexandru-pocovnicu 3b0d529
updated the code according to the test cases
alexandru-pocovnicu 66ab144
wrote the test cases
alexandru-pocovnicu 93f777e
wrote the code according to test cases
alexandru-pocovnicu 9e994f7
adjusted tests and code according to review
alexandru-pocovnicu 46128d9
added a few more tests for edge cases
alexandru-pocovnicu dd284bc
simplified the code by adding else
alexandru-pocovnicu c20a08d
check for angles<0
alexandru-pocovnicu 9ba4e9f
return false instead of NaN
alexandru-pocovnicu 816bd57
added stricter rule for what rank can be
alexandru-pocovnicu 83a5879
added tests for more invalid card ranks
alexandru-pocovnicu c2bb55d
updated tests and code to include all possibilities
alexandru-pocovnicu cdbc4b1
created a for loop to test the card from 2-10
alexandru-pocovnicu 56922bb
generalised test for j q k
alexandru-pocovnicu 8b04dcb
filter out non-numbers and non-integers
alexandru-pocovnicu 531f1a3
changed return from string to boolean
alexandru-pocovnicu 4db0d4f
check if the function can also return false
alexandru-pocovnicu 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
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,24 +1,46 @@ | ||
const getAngleType = require("./1-get-angle-type"); | ||
|
||
test("should identify right angle (90°)", () => { | ||
test("should return not an angle (angle=0)", () => { | ||
expect(getAngleType(0)).toEqual("Not an angle"); | ||
}); | ||
|
||
test("should identify right angle (angle=90°)", () => { | ||
expect(getAngleType(90)).toEqual("Right angle"); | ||
}); | ||
|
||
// REPLACE the comments with the tests | ||
// make your test descriptions as clear and readable as possible | ||
// make your test descriptions as clear and readable as possible. | ||
|
||
// Case 2: Identify Acute Angles: | ||
// When the angle is less than 90 degrees, | ||
// Then the function should return "Acute angle" | ||
|
||
// Case 3: Identify Obtuse Angles: | ||
// When the angle is greater than 90 degrees and less than 180 degrees, | ||
// Then the function should return "Obtuse angle" | ||
test("should identify acute angle (0 < angle < 90)",()=>{ | ||
expect(getAngleType(45)).toEqual("Acute angle"); | ||
expect(getAngleType(89.9)).toEqual("Acute angle"); | ||
expect(getAngleType(20.6)).toEqual("Acute angle"); | ||
}); | ||
|
||
|
||
test("should identify obtuse angle(90° < angle < 180°)",()=>{ | ||
expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
expect(getAngleType(90.1)).toEqual("Obtuse angle") | ||
expect(getAngleType(179.9)).toEqual("Obtuse angle") | ||
}); | ||
|
||
|
||
// Case 4: Identify Straight Angles: | ||
// When the angle is exactly 180 degrees, | ||
// Then the function should return "Straight angle" | ||
test("should identify straight angle(angle=180°)",()=>{ | ||
expect(getAngleType(180)).toEqual("Straight angle") | ||
}); | ||
|
||
|
||
test("should identify reflex angle(180<angle<=360)",()=>{ | ||
expect(getAngleType(230)).toEqual("Reflex angle") | ||
expect(getAngleType(180.1)).toEqual("Reflex angle"); | ||
expect(getAngleType(360)).toEqual("Reflex angle"); | ||
}); | ||
|
||
test("should identify revolutional angle(angle>360)", () => { | ||
expect(getAngleType(390)).toEqual("Revolutional angle"); | ||
}); | ||
|
||
// Case 5: Identify Reflex Angles: | ||
// When the angle is greater than 180 degrees and less than 360 degrees, | ||
// Then the function should return "Reflex angle" | ||
test("should identify a negative angle(angle<0)", () => { | ||
expect(getAngleType(-390)).toEqual("Negative angle"); | ||
}); |
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,13 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
if (isNaN(numerator) || isNaN(denominator)) return false; | ||
if (Math.abs(numerator) < Math.abs(denominator)) { | ||
return true}else{ | ||
return false; | ||
}; | ||
|
||
|
||
|
||
// add your completed function from key-implement here. | ||
} | ||
|
||
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,18 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
// replace with your code from key-implement... | ||
let rank=card.slice(0,-1); | ||
if (rank === "A") return 11; | ||
const allrank=["2","3","4","5","6","7","8","9","10"] | ||
if(allrank.includes(rank))return Number(rank); | ||
if(rank==="10"|| rank==="J" || rank==="Q" || rank==="K") return 10; | ||
else return "Invalid card rank"; | ||
|
||
} | ||
module.exports = getCardValue; | ||
module.exports = getCardValue; | ||
|
||
|
||
// console.log(getCardValue("0x02♠")); | ||
// console.log(getCardValue("2.1♠")); | ||
// console.log(getCardValue("00_02♠")); | ||
// console.log(getCardValue("3e0♠")); | ||
// console.log(getCardValue("000002♠")); |
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 |
---|---|---|
|
@@ -5,7 +5,37 @@ test("should return 11 for Ace of Spades", () => { | |
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
// Case 2: Handle Number Cards (2-10):.. | ||
test("should return Number Cards (2-10)", () => { | ||
for (let i=2; i<=10;i++){ | ||
const card = i + "♠" | ||
expect(getCardValue(card)).toEqual(i); | ||
} | ||
}); | ||
test("should return 2 for 2 of Spades", () => { | ||
const twoofSpades = getCardValue("2♠"); | ||
expect(twoofSpades).toEqual(2); | ||
}) | ||
// Case 3: Handle Face Cards (J, Q, K):. | ||
test("should return 10 for Face Cards (J, Q, K)", () => { | ||
const jofSpades = getCardValue("J♠"); | ||
expect(jofSpades).toEqual(10); | ||
expect(getCardValue("K♠")).toEqual(10); | ||
expect(getCardValue("Q♠")).toEqual(10) | ||
}); | ||
// Case 4: Handle Ace (A): | ||
test("should return 11 for Ace of Heart",()=>{ | ||
const aceofHeart = getCardValue("A♥"); | ||
expect(aceofHeart).toEqual(11); | ||
}) | ||
// Case 5: Handle Invalid Cards: | ||
test("should return invalid cards for anything else",()=>{ | ||
expect(getCardValue("l")).toBe("Invalid card rank") | ||
}) | ||
|
||
test("should return invalid cards for anything else", () => { | ||
expect(getCardValue("2.1♠")).toBe("Invalid card rank"); | ||
}); | ||
test("should return invalid cards for anything else", () => { | ||
expect(getCardValue("00_02♠")).toBe("Invalid card rank"); | ||
}); | ||
Comment on lines
+35
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could combine these into one tests, as both of them are testing for invalid card ranks. |
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,5 @@ | ||
function countChar(stringOfCharacters, findCharacter) { | ||
return 5 | ||
return stringOfCharacters.split("").filter((char)=>char===findCharacter).length | ||
} | ||
|
||
//console.log(countChar("heello","l")) | ||
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
25 changes: 23 additions & 2 deletions
25
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,26 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
|
||
if (isNaN(num) || (!Number.isInteger(num))) { | ||
return "NaN"; | ||
} | ||
|
||
const strNum=String(num); | ||
const lastDigit=Number(strNum.slice(-1)); | ||
const lastTwoDigits=Number(strNum.slice(-2)); | ||
|
||
if (lastTwoDigits >= 11 && lastTwoDigits <=13) return num + "th"; | ||
|
||
if(lastDigit===1)return num + "st"; | ||
|
||
if ( lastDigit===2) return num + "nd"; | ||
|
||
if (lastDigit === 3) return num + "rd"; | ||
|
||
return num+"th" | ||
|
||
} | ||
|
||
module.exports = getOrdinalNumber; | ||
|
||
module.exports = getOrdinalNumber; | ||
|
||
|
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.
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.
Can you improve the indentation of this code?
This is the suggested style by CYF: https://curriculum.codeyourfuture.io/guides/reviewing/style-guide/