generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Karla Grajales | Sprint-3 - Module-Structuring-and-Testing-Data | SPRINT 3 #238
Open
Grajales-K
wants to merge
32
commits into
CodeYourFuture:main
Choose a base branch
from
Grajales-K: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.
+4,555
−91
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
d97f55b
initializing the function to identify angles
Grajales-K 17e5647
removed function
Grajales-K 3d51b68
installed npm dependencies to test with Jest
Grajales-K 6a0595d
added console.assert() test for get-angle-type.js
Grajales-K ae24499
implemented test with jest and update name of the file as get-angle-t…
Grajales-K ca012a7
chabged the script to jest
Grajales-K 4a61d73
adding conditon to handle differents options
Grajales-K 121696e
changed to more easy function with if statements
Grajales-K 48e6a8c
added the console.assert test
Grajales-K 3ba6e74
isProperFraction easy estructured
Grajales-K 6de4e81
added isValidTriangle fuction
Grajales-K 1d07973
rotateCharacter function done
Grajales-K 8303039
console.log test done
Grajales-K 777d332
rotate-char.js update lines spaces
Grajales-K 89fcaf5
Added comment to explain how the code runs
Grajales-K a733352
added function countChar
Grajales-K ebd07d2
is-valid-triangle.js updated
Grajales-K 05b00c9
added password.js file and test cases
Grajales-K 801006e
added the function repeatString
Grajales-K d04bbba
added some comments in the function
Grajales-K 9c9fc1a
added isPrime function
Grajales-K ce6c536
added test cases for isPrime fuction
Grajales-K 3e9b02e
added repeat fuction and comments of how code is working
Grajales-K ad68622
updated function name from ordinal.js to get-ordinal-number.js
Grajales-K 08136b1
added comments to the function getOrdinalNumber
Grajales-K 3ba56dc
validate and handle cases with 0 and decimal numbers and letter no in…
Grajales-K bf0e4d8
validate negative numbers in the function
Grajales-K 2396b83
validate in one line the triangle inequality
Grajales-K d06f31f
validate the short password in the test
Grajales-K dad6802
fixed commentarios and funcionality in thes and functions
Grajales-K dfdc1bf
update comments
Grajales-K 180ac5d
added console.assert test
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 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 was deleted.
Oops, something went wrong.
This file contains 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,113 @@ | ||
// Implement a function getAngleType | ||
|
||
// Acceptance criteria: | ||
|
||
// Given an angle in degrees, | ||
// When the function getAngleType is called with this angle, | ||
// Then it should: | ||
|
||
// 1. Identify Right Angles: | ||
// When the angle is exactly 90 degrees, | ||
// Then the function should return "Right angle" | ||
|
||
// 2. Identify Acute Angles: | ||
// When the angle is less than 90 degrees", | ||
// Then the function should return "Acute angle" | ||
|
||
// 3. Identify Obtuse Angles: | ||
// When the angle is greater than 90 degrees and less than 180 degrees, | ||
// Then the function should return "Obtuse angle" | ||
|
||
// 4. Identify Straight Angles: | ||
// When the angle is exactly 180 degrees, | ||
// Then the function should return "Straight angle" | ||
|
||
// 5. Identify Reflex Angles: | ||
// When the angle is greater than 180 degrees and less than 360 degrees, | ||
// Then the function should return "Reflex angle" | ||
|
||
|
||
// ============================= function getAngleType =============================== | ||
//the use of else if is to compare one of the conditions | ||
|
||
function getAngleType(angle){ | ||
|
||
if (angle === 90) { | ||
return "Right angle"; | ||
} else if (angle > 0 && 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"; | ||
} | ||
return "Invalid angle"; | ||
} | ||
|
||
|
||
// console.log(getAngleType(90)); // "Right angle" | ||
// console.log(getAngleType(45)); // "Acute angle" | ||
// console.log(getAngleType(135)); // "Obtuse angle" | ||
// console.log(getAngleType(180)); // "Straight angle" | ||
// console.log(getAngleType(270)); // "Reflex angle" | ||
// console.log(getAngleType(-30)); // "Invalid angle" | ||
|
||
|
||
|
||
// ============== test with console.assert() ================== | ||
//these test are more simple to write and read and only return the fail message | ||
// console.assert(expression, message); | ||
|
||
console.assert(getAngleType(99) === "Right angle", "Test case failed for Right Angle"); // fail AssertionError [ERR_ASSERTION]: Test case failed for Right Angle | ||
console.assert(getAngleType(40) === "Acute angle", "Test case failed for Acute Angle"); | ||
console.assert(getAngleType(135) === "Obtuse Angle", "test case failed for Obtuse Angle"); | ||
console.assert(getAngleType(380) === "Straight angle", "Test failed for Straight angle"); // fail AssertionError [ERR_ASSERTION]: Test failed for Straight angle | ||
console.assert(getAngleType(270) === "Reflex Angle", "Test case Failed for Reflex Angle"); | ||
console.assert(getAngleType(-10) === "Invalid angle", "Test case Failed for Invalid angle"); | ||
console.assert(getAngleType(400) === "Invalid angle", "Test case Failed for Invalid Angle"); | ||
|
||
|
||
|
||
// ============== test with Jest ================== | ||
// These tests are more detailed because we can see what was expected and what went wrong | ||
test('Should return "Right angle" for 90 degrees', () => { | ||
const result = getAngleType(90); | ||
expect(result).toBe("Right angle"); | ||
}); | ||
|
||
test('Should return "Acute angle" for angles between 0 and 90', () => { | ||
const result = getAngleType(35); | ||
expect(result).toBe("Acute angle"); | ||
}); | ||
|
||
test('Should return "Obtuse Angle" for angles between 90 and 180', () => { | ||
const result = getAngleType(135); | ||
expect(result).toBe("Obtuse Angle"); | ||
}); | ||
|
||
test('Should return "Straight angle" for 180 degrees', () => { | ||
const result = getAngleType(180); | ||
expect(result).toBe("Straight angle"); | ||
}); | ||
|
||
test('Should return "Reflex Angle" for angles between 180 and 360', () => { | ||
const result = getAngleType(270); | ||
expect(result).toBe("Reflex Angle"); | ||
}); | ||
|
||
test('Should return "Invalid angle" for angles outside 0-360 degrees', () => { | ||
expect(getAngleType(-10)).toBe("Invalid angle"); | ||
expect(getAngleType(400)).toBe("Invalid angle"); | ||
}); | ||
|
||
|
||
|
||
|
||
|
||
//nodemon | ||
// to run these test and see the changes applied in the same time use < nodemon -x "npm test" get-angle-type.test.js > | ||
|
||
// npm | ||
//once you are inside of the file you want to run < npm test -- --watch > |
This file contains 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 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 |
---|---|---|
|
@@ -25,10 +25,36 @@ | |
// Negative Fraction check: | ||
// Input: numerator = -4, denominator = 7 | ||
// target output: true | ||
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true. | ||
// Explanation: The fraction -4/7 is a proper fraction because | ||
// the absolute value of the numerator (4) is less than the denominator (7). The function should return true. | ||
|
||
// Equal Numerator and Denominator check: | ||
// Input: numerator = 3, denominator = 3 | ||
// target output: false | ||
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. | ||
// These acceptance criteria cover a range of scenarios to ensure that the isProperFraction function handles both proper and improper fractions correctly and handles potential errors such as a zero denominator. | ||
|
||
function isProperFraction(numerator, denominator) { | ||
// Check for denominator being zero | ||
if (denominator === 0) { | ||
throw new Error("Denominator cannot be zero"); | ||
} | ||
|
||
// If numerator is equal to denominator, it's not a proper fraction | ||
if (numerator === denominator) { | ||
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. The condition at line 49 can also handle this case. |
||
return false; | ||
} | ||
|
||
// Proper fraction if the absolute value of the numerator is less than the denominator | ||
return Math.abs(numerator) < Math.abs(denominator); | ||
} | ||
|
||
// Test cases | ||
console.log(isProperFraction(3, 6)); // true | ||
console.log(isProperFraction(-3, 6)); // true | ||
console.log(isProperFraction(5, 5)); // false | ||
console.log(isProperFraction(-4, 7)); // true | ||
console.log(isProperFraction(4, -7)); // true | ||
console.log(isProperFraction(-4, -7)); // true | ||
console.log(isProperFraction(9, 0)); // Error: Denominator cannot be zero | ||
|
This file contains 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.
A string representing a decimal numbers such as "2.3" could still pass this test.
A bulletproof approach would be to check if
rank
is exactly one of "2", "3", ..., "10" before doing the number conversion.