generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 195
Sheffield| May 2025| Mayowa Fadare| Structure testing sprint 3 #633
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
mayowa0-7
wants to merge
11
commits into
CodeYourFuture:main
Choose a base branch
from
mayowa0-7:Structure-testing-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 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3b13a90
completed the code to pass the remaining angles
mayowa0-7 cd2d9f1
fraction code testdone
mayowa0-7 b3bfd4b
made changes to the card values
mayowa0-7 eb25c34
using the template, i made some corrections to the mandatory-rewrite
mayowa0-7 52cc4a3
mandatory practice done
mayowa0-7 339c2ba
made changes to validate the card
mayowa0-7 14c036b
created a new file for card validator and ran the code
mayowa0-7 c7ccd98
card validator cheked and passed using npx
mayowa0-7 5981bd2
run, tested and passed npx test
mayowa0-7 989265d
all tested and passed the jest test
mayowa0-7 d465d6a
card value function fixed
mayowa0-7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
|
||
function isProperFraction(numerator, denominator) { | ||
if (numerator < denominator) return true;} | ||
if (Math.abs(numerator) < Math.abs(denominator)) { | ||
return true; | ||
} { return false; } | ||
if (numerator < denominator) { | ||
return true; | ||
} if (numerator === denominator) { | ||
return false; | ||
} if (denominator === 0) { | ||
return false; | ||
} | ||
// Check for invalid fraction (denominator cannot be zero) | ||
if (denominator === 0) { | ||
return false; | ||
} | ||
// Check if the absolute value of the numerator is less than the absolute value of the denominator | ||
return Math.abs(numerator) < Math.abs(denominator); | ||
} | ||
|
||
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
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
38 changes: 17 additions & 21 deletions
38
Sprint-3/3-mandatory-practice/implement/get-ordinal-number.test.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,39 +1,35 @@ | ||
const getOrdinalNumber = require("./get-ordinal-number"); | ||
// In this week's prep, we started implementing getOrdinalNumber | ||
|
||
// continue testing and implementing getOrdinalNumber for additional cases | ||
// Write your tests using Jest - remember to run your tests often for continual feedback | ||
|
||
// Case 1: Identify the ordinal number for 1 | ||
// When the number is 1, | ||
// Then the function should return "1st" | ||
|
||
const getOrdinalNumber = require("./getOrdinalNumber"); | ||
|
||
test("should return 1st", () => { | ||
expect(getOrdinalNumber(1)).toEqual("1st"); | ||
}); | ||
|
||
test("should return 2nd", () => { | ||
expect(getOrdinalNumber(2)).toEqual("2nd"); | ||
test("returns 1st for 1", () => { | ||
expect(getOrdinalNumber(1)).toBe("1st"); | ||
}); | ||
|
||
test("should return 3rd", () => { | ||
expect(getOrdinalNumber(3)).toEqual("3rd"); | ||
test("returns 2nd for 2", () => { | ||
expect(getOrdinalNumber(2)).toBe("2nd"); | ||
}); | ||
|
||
test("should return 8th", () => { | ||
expect(getOrdinalNumber(8)).toEqual("8th"); | ||
test("returns 3rd for 3", () => { | ||
expect(getOrdinalNumber(3)).toBe("3rd"); | ||
}); | ||
|
||
test("should return 19th", () => { | ||
expect(getOrdinalNumber(19)).toEqual("19th"); | ||
test("returns 4th for 4", () => { | ||
expect(getOrdinalNumber(4)).toBe("4th"); | ||
}); | ||
|
||
test("should return 81st", () => { | ||
expect(getOrdinalNumber(81)).toEqual("81st"); | ||
test("Handle the special case for teens (11, 12, 13)", () => { | ||
expect(getOrdinalNumber(11)).toBe("11th"); | ||
expect(getOrdinalNumber(12)).toBe("12th"); | ||
expect(getOrdinalNumber(13)).toBe("13th"); | ||
}); | ||
|
||
test("should return 125th", () => { | ||
expect(getOrdinalNumber(125)).toEqual("125th"); | ||
test("Get the last digit to determine suffix", () => { | ||
expect(getOrdinalNumber(21)).toBe("21st"); | ||
expect(getOrdinalNumber(22)).toBe("22nd"); | ||
expect(getOrdinalNumber(23)).toBe("23rd"); | ||
expect(getOrdinalNumber(101)).toBe("101st"); | ||
}); |
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,11 +1,9 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
} | ||
|
||
module.exports = repeat; | ||
function repeat(str = "", count = 1) { | ||
if (count < 0) { | ||
throw new Error("Invalid count"); | ||
} | ||
|
||
function repeat(word = "hello", times = 3) { | ||
return word.repeat(times); | ||
return str.repeat(count); | ||
} | ||
|
||
module.exports = repeat; |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function validateCreditCard(cardNumber) { | ||
// Check length and numeric characters | ||
if (cardNumber.length !== 16 || !/^\d{16}$/.test(cardNumber)) { | ||
return false; | ||
} | ||
|
||
// Check at least two different digits | ||
const uniqueDigits = new Set(cardNumber); | ||
if (uniqueDigits.size < 2) { | ||
return false; | ||
} | ||
|
||
// Check last digit is even | ||
const lastDigit = Number(cardNumber[cardNumber.length - 1]); | ||
if (lastDigit % 2 !== 0) { | ||
return false; | ||
} | ||
|
||
// Check sum of digits | ||
let digitSum = 0; | ||
for (let digit of cardNumber) { | ||
digitSum += Number(digit); | ||
} | ||
if (digitSum <= 16) { | ||
return false; | ||
} | ||
|
||
// If all checks passed, return true | ||
return true; | ||
} | ||
|
||
module.exports = validateCreditCard; |
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
cjyuan marked this conversation as resolved.
Show resolved
Hide resolved
|
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,39 +1,29 @@ | ||
function passwordValidator(password) { | ||
return password.length < 5 ? false : true | ||
} | ||
function passwordValidator(password) { | ||
return password.length >= 5; | ||
} | ||
// Checks whether the password variable is a string | ||
if (typeof password !== 'string') return false; | ||
const previousPasswords = ["Password123!", "Welcome1$", "Admin#2023"]; // example previous passwords list | ||
|
||
// Check length is at least a maximum of 5 characters long | ||
if (password.length < 5) return true; | ||
|
||
// Check for at least one uppercase letter A-Z | ||
if (!/[A-Z]/.test(password)) return false; | ||
function passwordValidator(password) { | ||
// Check that password is a string | ||
if (typeof password !== "string") return false; | ||
|
||
// Check for at least one lowercase letter a-z | ||
if (!/[a-z]/.test(password)) return false; | ||
// Check minimum length | ||
if (password.length < 5) return false; | ||
|
||
// Check for at least one number 0-9 | ||
if (!/[0-9]/.test(password)) return false; | ||
// Check for at least one uppercase letter | ||
if (!/[A-Z]/.test(password)) return false; | ||
|
||
// Check for at least one allowed special character: ! # $ % . * & | ||
if (!/[!#$%.*&]/.test(password)) return false; | ||
// Check for at least one lowercase letter | ||
if (!/[a-z]/.test(password)) return false; | ||
|
||
// Check that password is not in previousPasswords array | ||
if (previousPasswords.includes(password)) return false; | ||
// Check for at least one digit | ||
if (!/[0-9]/.test(password)) return false; | ||
|
||
// If all checks pass, return true | ||
return true; | ||
// Check for at least one special character from allowed set | ||
if (!/[!#$%.*&]/.test(password)) return false; | ||
|
||
// Check password not previously used | ||
if (previousPasswords.includes(password)) return false; | ||
|
||
// If all checks pass, password is valid | ||
return true; | ||
} | ||
|
||
const hasUppercase = /[A-Z]/.test(password); | ||
const hasLowercase = /[a-z]/.test(password); | ||
const hasDigit = /[0-9]/.test(password); | ||
const hasSpecialChar = /[!@#$%^&*(),.?":{}|<>]/.test(password); | ||
const hasNoSpaces = !/\s/.test(password); | ||
|
||
module.exports = passwordValidator; | ||
module.exports = passwordValidator; |
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.