diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d..a7310ad34 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,8 @@ -function countChar(stringOfCharacters, findCharacter) { - return 5 +function countChar(str, char) { + + return str.split(char).length -1; } -module.exports = countChar; +console.log(countChar('lol', 'l')); + +module.exports = countChar; \ No newline at end of file diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index f95d71db1..def003de7 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,5 +1,11 @@ -function getOrdinalNumber(num) { - return "1st"; +function getOrdinalNumber(n) { + if (n % 100 >= 11 && n % 100 <= 13) return n + "th"; + + if (n % 10 === 1) return n + "st"; + if (n % 10 === 2) return n + "nd"; + if (n % 10 === 3) return n + "rd"; + + return n + "th"; } -module.exports = getOrdinalNumber; +module.exports = getOrdinalNumber; \ No newline at end of file diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 3838c7b00..c6e2f8ddd 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,7 @@ -function repeatStr() { - return "hellohellohello"; -} +function repeatStr(str, count) { + if( count >= 0 ) + {return str.repeat (count)}; +else { return 'invalid count'}; +}; -module.exports = repeatStr; +module.exports = repeatStr; \ No newline at end of file