-
-
Notifications
You must be signed in to change notification settings - Fork 337
West Midlands | Sept-ITP-25 | Mustaf Asani | Sprint 3 | Coursework/sprint 3 practice tdd #813
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
Changes from 4 commits
c518625
51060d9
1a6131d
83c98dc
752f7ae
f04aba1
d754f5a
af1e37a
fea77f0
eac5a16
aec1685
772fae8
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,13 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| let pattern = new RegExp(findCharacter, "g"); | ||
|
|
||
| let matchingChars = stringOfCharacters.match(pattern); | ||
|
|
||
| if (matchingChars === null) { | ||
| return 0; | ||
| } | ||
|
|
||
| return matchingChars.length; | ||
| } | ||
|
|
||
| module.exports = countChar; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,14 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
| if (num === 1) { | ||
| return "1st"; | ||
| } else if (num === 2) { | ||
| return "2nd"; | ||
| } else if (num === 3) { | ||
| console.log(num); | ||
| return "3rd"; | ||
| } else if (num > 3 || num < 21) { | ||
| return `${num}th`; | ||
| } | ||
|
asaniDev marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,15 @@ const getOrdinalNumber = require("./get-ordinal-number"); | |
| test("should return '1st' for 1", () => { | ||
| expect(getOrdinalNumber(1)).toEqual("1st"); | ||
| }); | ||
|
|
||
| test("should return '2nd' for 2", () => { | ||
| expect(getOrdinalNumber(2)).toEqual("2nd"); | ||
| }); | ||
|
|
||
| test("should return '3rd' for 3", () => { | ||
| expect(getOrdinalNumber(3)).toEqual("3rd"); | ||
|
asaniDev marked this conversation as resolved.
Outdated
|
||
| }); | ||
|
|
||
| test("should return any number between 4 and 20 with a suffix of 'th' at end of number", () => { | ||
| expect(getOrdinalNumber(10)).toEqual("10th"); | ||
| }); | ||
|
Comment on lines
+11
to
41
Contributor
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. These tests are quite comprehensive. If you use this test script to test your implementation, you can discover some bug in your code.
Author
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. added code to catch negative and non-integer values |
||
Uh oh!
There was an error while loading. Please reload this page.