You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adjustments made on the 2-practice-tdd files to implement the repeatStr function and add test cases for it. The repeatStr function now uses the built-in repeat method to return the string repeated a specified number of times. Additionally, test cases have been added to verify the behavior of the function when the count is 1, 0, and negative.
Copy file name to clipboardExpand all lines: Sprint-3/2-practice-tdd/count.js
+17Lines changed: 17 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,20 @@ function countChar(stringOfCharacters, findCharacter) {
3
3
}
4
4
5
5
module.exports=countChar;
6
+
//
7
+
8
+
//Below is the implementation of the countChar function that counts the number of times a character occurs in a string.
9
+
// The function takes two parameters: `stringOfCharacters`, which is the string to search through, and `findCharacter`, which is the character to count.
10
+
// The function initializes a counter to 0 and iterates through each character in the string. If the current character matches `findCharacter`, the counter is incremented. Finally, the function returns the total count.
Copy file name to clipboardExpand all lines: Sprint-3/2-practice-tdd/get-ordinal-number.js
+25Lines changed: 25 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,28 @@ function getOrdinalNumber(num) {
3
3
}
4
4
5
5
module.exports=getOrdinalNumber;
6
+
// Below is the implementation of the getOrdinalNumber function that converts a number to its ordinal form (e.g., 1 to "1st", 2 to "2nd", etc.).
7
+
// The function takes a single parameter `num`, which is the number to convert.
8
+
// It checks the last digit of the number to determine the appropriate suffix ("st", "nd", "rd", or "th") and returns the number concatenated with its ordinal suffix as a string.
Copy file name to clipboardExpand all lines: Sprint-3/2-practice-tdd/repeat-str.js
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -3,3 +3,11 @@ function repeatStr() {
3
3
}
4
4
5
5
module.exports=repeatStr;
6
+
// Below is the implementation of the repeatStr function that takes a string and a number as parameters and returns the string repeated the specified number of times.
7
+
// The function uses the built-in `repeat` method of strings to achieve this. It takes the input string and repeats it `n` times, where `n` is the number provided as the second parameter.
0 commit comments