diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d..c377378c9 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,11 @@ -function countChar(stringOfCharacters, findCharacter) { - return 5 +function countChar(str, char) { + let count = 0; + for (let i = 0; i < str.length; i++) { + if (str[i] === char) { + count++; + } + } + return count; } module.exports = countChar; diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index f95d71db1..b0aeaba47 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,5 +1,17 @@ function getOrdinalNumber(num) { - return "1st"; + nonStr = num.toString(); + if (nonStr.endsWith("1") && nonStr !== "11") { + return nonStr.concat("st"); + } else if (nonStr.endsWith("2")) { + return nonStr.concat("nd"); + } else if (nonStr.endsWith("3")) { + return nonStr.concat("rd"); + } else { + return "Invalid"; + } + } module.exports = getOrdinalNumber; + + diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 3838c7b00..7850fb691 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,5 @@ -function repeatStr() { - return "hellohellohello"; +function repeatStr(str, count) { + return str.repeat(count); } module.exports = repeatStr; diff --git a/i b/i new file mode 100644 index 000000000..577d956ee --- /dev/null +++ b/i @@ -0,0 +1,7 @@ +* 1-implement-and-rewrite-tests + 3-dead-code + Sprint-3/2-practice-tdd + acoursework/sprint-2 + acoursework/sprint-2_old + coursework/sprint-3-implement-and-rewrite + main