generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
London | ITP-May-2025 | Surafel Workneh| Sprint-3 #637
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
SuWebOnes
wants to merge
32
commits into
CodeYourFuture:main
Choose a base branch
from
SuWebOnes: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
32 commits
Select commit
Hold shift + click to select a range
ba7c348
update: Implement angle type identification in getAngleType function
SuWebOnes e6d6e76
UPdate: fix isProperFraction function to handle negative numbers and …
SuWebOnes cea3512
Update: fix getCardValue function to handle face cards, numeric ranks…
SuWebOnes d375cee
Update: fix getAngleType function to improve readability and ensure …
SuWebOnes f66a15a
Update: fix and test descriptions for angle type identification for c…
SuWebOnes e67b162
Update: comment out example console logs in getAngleType function for…
SuWebOnes 0a7cda4
Update: test isProperFraction function to include comprehensive check…
SuWebOnes 87fc686
Update: test isProperFraction function is correct and reintroduce usa…
SuWebOnes a52f2c1
Update: implement getCardValue function to return correct card values…
SuWebOnes e2c54d6
Update: fix test cases in getCardValue to improve readability and con…
SuWebOnes 1014714
Update: fix countChar function with correct implementation and add ex…
SuWebOnes af66632
Update: add test case for countChar function to verify function
SuWebOnes a5879e7
Update: implement getOrdinalNumber function to return correct ordinal…
SuWebOnes e255a25
Update: fix code and test in getOrdinalNumber test case
SuWebOnes 9b9d6fa
Update: fix repeat function to accept parameters and handle non-negat…
SuWebOnes 4c03b27
Update: test cases in repeat.test.js for clarity
SuWebOnes d0371be
Update: comments foe questions to explain code in find.js for better…
SuWebOnes 094657b
Update: fix password validation logic and comment out test cases
SuWebOnes d457ddd
Update: password validation test for consistency and clarity
SuWebOnes 729f88f
update: Implement getAngleType function with tests for angle classifi…
SuWebOnes d17fa1d
update: Implement dir and ext extraction logic in 3-paths.js
SuWebOnes affd78a
update: fix ext extraction logic in 3-paths.js
SuWebOnes 93fae64
update: add comment to ext extraction logic for clarity
SuWebOnes 635a1a0
Update 3-paths.js
SuWebOnes 2bfd808
changed log statement
SuWebOnes 7c6010a
Update 3-get-card-value.js
SuWebOnes eed725e
Update 2-is-proper-fraction.js
SuWebOnes 9c478cd
Update count.test.js
SuWebOnes 8cb7495
update: include code for denominator must not be zero
SuWebOnes 14e256e
update: testing case1 count times
SuWebOnes 922ebf5
update: test cases for repeat.test.js
SuWebOnes ddf577d
update: fix password validation tests for minimum length, reused and …
SuWebOnes 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,18 +1,33 @@ | ||
function getAngleType(angle) { | ||
if (angle === 90) return "Right angle"; | ||
// replace with your completed function from key-implement | ||
// Step 1: Check for a right angle (exactly 90 degrees) | ||
if (angle === 90) return "Right angle"; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
// Step 2: Check for a straight angle (exactly 180 degrees) | ||
if (angle === 180) return "Straight angle"; | ||
|
||
// Step 3: Check for an acute angle (between 0 and 90) | ||
if (angle > 0 && angle < 90) return "Acute Angle"; | ||
|
||
// Step 4: Check for an obtuse angle (between 90 and 180) | ||
if (angle > 90 && angle < 180) return "Obtuse angle"; | ||
// Step 5: Check for a reflex angle (between 180 and 360) | ||
if (angle > 180 && angle < 360) return "Reflex angle"; | ||
|
||
// Step 6: Handle invalid or unsupported input | ||
return "Invalid 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 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; | ||
|
||
// console.log(getAngleType(90)); // "Right angle" | ||
// console.log(getAngleType(180)); // "Straight angle" | ||
// console.log(getAngleType(45)); // "Acute angle" | ||
// console.log(getAngleType(120)); // "Obtuse angle" | ||
// console.log(getAngleType(0)); // "Invalid angle" | ||
// console.log(getAngleType(200)); // "Invalid angle" | ||
// console.log(getAngleType(90.5)); // "Invalid 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,24 +1,31 @@ | ||
const getAngleType = require("./1-get-angle-type"); | ||
const getAngleType = require("./1-get-angle-type"); // Import the function to be tested | ||
|
||
test("should identify right angle (90°)", () => { | ||
expect(getAngleType(90)).toEqual("Right angle"); | ||
}); | ||
|
||
// REPLACE the comments with the tests | ||
// 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" | ||
|
||
test("should identify Acute Angles (< 90)", () => { | ||
expect(getAngleType(45)).toEqual("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 Obtuse angle (>90 && <180)", () => { | ||
expect(getAngleType(120)).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 (180°)", () => { | ||
expect(getAngleType(180)).toEqual("Straight 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 Straight Angle (> 180 && < 360)", () => { | ||
expect(getAngleType(278)).toEqual("Reflex 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,19 @@ | ||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true; | ||
// add your completed function from key-implement here | ||
if (denominator === 0) return false; // Avoid division by zero | ||
if (numerator < 0 || denominator < 0) return false; // Proper fractions are positive | ||
if (numerator < denominator) return true; // Proper if numerator < denominator | ||
return false; // Otherwise, it's improper | ||
} | ||
|
||
module.exports = isProperFraction; | ||
module.exports = isProperFraction; | ||
// Test cases for the isProperFraction function | ||
console.log(isProperFraction(1, 2)); // true | ||
console.log(isProperFraction(3, 4)); // true | ||
console.log(isProperFraction(5, 5)); // false | ||
console.log(isProperFraction(7, 6)); // false | ||
console.log(isProperFraction(0, 1)); // true | ||
console.log(isProperFraction(1, 0)); // false (denominator is zero) | ||
console.log(isProperFraction(-1, 2)); // false (negative numerator) | ||
console.log(isProperFraction(1, -2)); // false (negative denominator) | ||
console.log(isProperFraction(-1, -2)); // false (both negative) | ||
console.log(isProperFraction(2, 3)); // true |
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,27 @@ | ||
const isProperFraction = require("./2-is-proper-fraction"); | ||
function isProperFraction(numerator, denominator) { | ||
// Case 1: Check for zero denominator (undefined) | ||
if (denominator === 0) return false; | ||
|
||
test("should return true for a proper fraction", () => { | ||
expect(isProperFraction(2, 3)).toEqual(true); | ||
}); | ||
// Case 2: Check for negative values (numerator or denominator) | ||
if (numerator < 0 || denominator < 0) return false; | ||
|
||
// Case 2: Identify Improper Fractions: | ||
// Case 3: Check for equal numerator and denominator | ||
if (numerator === denominator) return false; | ||
|
||
// Case 3: Identify Negative Fractions: | ||
// Case 4: Check for proper fraction (numerator < denominator) | ||
return numerator < denominator; | ||
} | ||
module.exports = isProperFraction; | ||
// usage examples | ||
console.log(isProperFraction(2, 3)); // true | ||
console.log(isProperFraction(5, 3)); // false | ||
console.log(isProperFraction(3, 3)); // false | ||
console.log(isProperFraction(-2, 3)); // false | ||
console.log(isProperFraction(2, -3)); // false | ||
console.log(isProperFraction(0, 5)); // true (0 < 5) | ||
console.log(isProperFraction(2, 2)); // false | ||
|
||
// Case 4: Identify Equal Numerator and Denominator: | ||
// Test cases for the isProperFraction function | ||
// test("should return true for a proper fraction", () => { | ||
// expect(isProperFraction(2, 3)).toEqual(true); | ||
// }); |
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,20 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
// replace with your code from key-implement | ||
// return 11; // always return 11 for testing purposes that is wrong | ||
const rank = card.slice(0, -1); // Extract rank (everything except the last character) | ||
if (rank === "A") return 11; // handle Ace as 11 | ||
if (["K", "Q", "J"].includes(rank)) return 10; // handle face cards as 10 | ||
const numericRank = parseInt(rank); //Handle number cards 2–9 | ||
if (numericRank >= 2 && numericRank <= 9) { | ||
return numericRank; // Return the numeric value for cards 2-9 | ||
} | ||
// Invalid card rank | ||
return 0; | ||
} | ||
module.exports = getCardValue; | ||
module.exports = getCardValue; | ||
|
||
// // Test cases | ||
console.log(getCardValue("A♠")); // 11 | ||
console.log(getCardValue("7♥")); // 7 | ||
console.log(getCardValue("K♦")); // 10 | ||
console.log(getCardValue("A♣")); // 11 |
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,27 @@ | ||
const getCardValue = require("./3-get-card-value"); | ||
|
||
test("should return 11 for Ace of Spades", () => { | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
const aceofSpades = getCardValue("A♠"); | ||
expect(aceofSpades).toEqual(11); | ||
}); | ||
|
||
// Case 2: Handle Number Cards (2-10): | ||
test("should return 7 for 7 of Hearts", () => { | ||
const sevenOfHearts = getCardValue("7♥"); | ||
expect(sevenOfHearts).toEqual(7); | ||
}); | ||
// Case 3: Handle Face Cards (J, Q, K): | ||
test("should return 10 for King of Diamonds", () => { | ||
const kingOfDiamonds = getCardValue("K♦"); | ||
expect(kingOfDiamonds).toEqual(10); | ||
}); | ||
// Case 4: Handle Ace (A): | ||
test("should return 11 for Ace of Clubs", () => { | ||
const aceOfClubs = getCardValue("A♣"); | ||
expect(aceOfClubs).toEqual(11); | ||
}); | ||
// Case 5: Handle Invalid Cards: | ||
test("should return 0 for invalid card 'X♠'", () => { | ||
const invalidCard = getCardValue("X♠"); | ||
expect(invalidCard).toEqual(0); | ||
}); |
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 | ||
// return 5; //This will always return 5, regardless of the inputs. So it’s just a placeholder. | ||
return stringOfCharacters.split(findCharacter).length - 1; | ||
} | ||
|
||
module.exports = countChar; | ||
module.exports = countChar; | ||
|
||
// console.log(countChar("hello", "l")); // 2 | ||
// console.log(countChar("hello world", "o")); // 2 | ||
// console.log(countChar("banana", "a")); // 3 | ||
// console.log(countChar("mississippi", "i")); // 5 |
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.
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.
Hi Surafel, good work on this. Just check that your function returns something for angles like 360 or any number outside 0 to 360. Right now, it doesn’t handle those cases.