Skip to content

Commit 049b7e5

Browse files
committed
Completion of tasks in 2-practice-tdd
1 parent 0e99abc commit 049b7e5

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

Sprint-3/2-practice-tdd/count.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
function countChar(stringOfCharacters, findCharacter) {
2-
return 5
1+
function countChar(str, char) {
2+
let count = 0;
3+
for (let i = 0; i < str.length; i++) {
4+
if (str[i] === char) {
5+
count++;
6+
}
7+
}
8+
return count;
39
}
410

511
module.exports = countChar;
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
function getOrdinalNumber(num) {
2-
return "1st";
2+
nonStr = num.toString();
3+
if (nonStr.endsWith("1") && nonStr !== "11") {
4+
return nonStr.concat("st");
5+
} else if (nonStr.endsWith("2")) {
6+
return nonStr.concat("nd");
7+
} else if (nonStr.endsWith("3")) {
8+
return nonStr.concat("rd");
9+
} else {
10+
return "Invalid";
11+
}
12+
313
}
414

515
module.exports = getOrdinalNumber;
16+
17+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function repeatStr() {
2-
return "hellohellohello";
1+
function repeatStr(str, count) {
2+
return str.repeat(count);
33
}
44

55
module.exports = repeatStr;

i

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
* 1-implement-and-rewrite-tests
2+
3-dead-code
3+
Sprint-3/2-practice-tdd
4+
acoursework/sprint-2
5+
acoursework/sprint-2_old
6+
coursework/sprint-3-implement-and-rewrite
7+
main

0 commit comments

Comments
 (0)