-
-
Notifications
You must be signed in to change notification settings - Fork 337
Glasgow | 26-ITP-Jan| Martin McLean |Sprint 3| practice TDD coursework #1025
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 7 commits
e6eb715
729b6d8
990e0cb
478b72b
b561db4
e6c3c69
7ae80a5
1cb231d
df08be5
d36bd0a
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,14 @@ | ||
| function countChar(stringOfCharacters, findCharacter) { | ||
| return 5 | ||
| totalCount=stringOfCharacters.split(""); | ||
|
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. What kind of variables are these intended to be? js lets you declare variables like this, but it is good practice to be a bit more specific. |
||
| Count=0 | ||
| for(i=0; i<totalCount.length; i++){ | ||
| if(totalCount[i]===findCharacter){ | ||
| Count++ | ||
| } | ||
| } | ||
|
|
||
| return Count | ||
| } | ||
| console.log(countChar("AAA","A")) | ||
| module.exports = countChar; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,21 @@ | ||
| function getOrdinalNumber(num) { | ||
| return "1st"; | ||
|
|
||
| if (num >=11 && num <= 19){ | ||
| return `${num}th` | ||
| }; | ||
|
|
||
|
|
||
| const lastDigit = num % 10 | ||
| switch (lastDigit) { | ||
| case 1: | ||
| return `${num}st`; | ||
| case 2: | ||
| return `${num}nd`; | ||
| case 3: | ||
| return `${num}rd`; | ||
| default: | ||
| return `${num}th`; | ||
| } | ||
| } | ||
|
|
||
| module.exports = getOrdinalNumber; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,8 @@ | ||
| function repeatStr() { | ||
| return "hellohellohello"; | ||
| } | ||
| function repeatStr(times, str) { | ||
| if (times < 0){ throw ("error")} | ||
|
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 ran this program and it just said "error" would that be enough info for you to figure out and solve the problem? Could this message be more specific? |
||
| return str.repeat(times); | ||
|
|
||
| } | ||
|
|
||
|
|
||
| module.exports = repeatStr; | ||
Uh oh!
There was an error while loading. Please reload this page.