-
-
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
base: main
Are you sure you want to change the base?
Changes from 18 commits
301ccc0
aee8b64
76d10a5
ae4f944
e282ccf
d81fcbb
777b1e7
9dcbdca
02ba073
7aab1ad
5eb2d42
743ea0a
cabdf43
5889529
244fe2e
3b0d529
66ab144
93f777e
9e994f7
46128d9
dd284bc
c20a08d
9ba4e9f
816bd57
83a5879
c2bb55d
cdbc4b1
56922bb
8b04dcb
531f1a3
4db0d4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
function getCardValue(card) { | ||
// replace with your code from key-implement | ||
return 11; | ||
let rank=card.slice(0,-1); | ||
if (rank === "A") return 11; | ||
if(rank>=2 && rank<10)return Number(rank); | ||
alexandru-pocovnicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(rank==="10"|| rank==="J" || rank==="Q" || rank==="K") return 10; | ||
else return "Invalid card rank" | ||
|
||
} | ||
module.exports = getCardValue; |
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; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
function getOrdinalNumber(num) { | ||
return "1st"; | ||
if (isNaN(num)) { | ||
return NaN; | ||
} | ||
alexandru-pocovnicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if(num>=11 && num<=13){ | ||
return num+"th" | ||
} | ||
|
||
if(num===1){ | ||
return num+"st" | ||
} | ||
if (num === 2) { | ||
return num + "nd"; | ||
} | ||
if (num === 3) { | ||
return num + "rd"; | ||
} | ||
return (num)+"th" | ||
} | ||
alexandru-pocovnicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
module.exports = getOrdinalNumber; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
function repeat() { | ||
return "hellohellohello"; | ||
function repeat(str,count) { | ||
if(count<0){ | ||
return "negative number" | ||
} | ||
alexandru-pocovnicu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return str.repeat(count); | ||
} | ||
|
||
//console.log(repeat("hello",3)) | ||
module.exports = repeat; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,13 +20,32 @@ test("should repeat the string count times", () => { | |
// Given a target string str and a count equal to 1, | ||
// When the repeat function is called with these inputs, | ||
// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition. | ||
test("should repeat the string count times", () => { | ||
const str = "hello"; | ||
const count = 1; | ||
const repeatedStr = repeat(str, count); | ||
expect(repeatedStr).toEqual("hello"); | ||
}); | ||
|
||
// case: Handle Count of 0: | ||
// Given a target string str and a count equal to 0, | ||
// When the repeat function is called with these inputs, | ||
// Then it should return an empty string, ensuring that a count of 0 results in an empty output. | ||
test("should repeat the string count times", () => { | ||
const str = "hello"; | ||
const count = 0; | ||
const repeatedStr = repeat(str, count); | ||
expect(repeatedStr).toEqual(""); | ||
}); | ||
|
||
|
||
// case: Negative Count: | ||
// Given a target string str and a negative integer count, | ||
// When the repeat function is called with these inputs, | ||
// Then it should throw an error or return an appropriate error message, as negative counts are not valid. | ||
test("should repeat the string count times", () => { | ||
const str = "hello"; | ||
const count = -1; | ||
const repeatedStr = repeat(str, count); | ||
expect(repeatedStr).toEqual("negative number"); | ||
}); | ||
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. If you modified 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. thank you but I couldn't understand the documetation |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,14 @@ | ||
function passwordValidator(password) { | ||
return password.length < 5 ? false : true | ||
} | ||
|
||
|
||
module.exports = passwordValidator; | ||
|
||
function passwordValidator(password,previousPasswords=[]) { | ||
if (previousPasswords.includes(password)) return false; | ||
const hasMinLength = password.length >= 5; | ||
const hasUpper = /[A-Z]/.test(password); | ||
const hasLower = /[a-z]/.test(password); | ||
const hasNumber = /[0-9]/.test(password); | ||
const hasSymbol = /[!#$%.*&]/.test(password); | ||
|
||
return hasMinLength && hasUpper && hasLower && hasNumber && hasSymbol; | ||
} | ||
|
||
module.exports = passwordValidator; |
Uh oh!
There was an error while loading. Please reload this page.