1- // Implement a function repeat
2- const repeat = require ( "./repeat" ) ;
1+ // Implement a function repeatStr
2+ const repeatStr = require ( "./repeat-str " ) ;
33// Given a target string str and a positive integer count,
4- // When the repeat function is called with these inputs,
4+ // When the repeatStr function is called with these inputs,
55// Then it should:
66function repeat ( str , count ) {
77 if ( count < 0 ) {
@@ -14,29 +14,29 @@ module.exports = repeat;
1414
1515// case: repeat String:
1616// Given a target string str and a positive integer count,
17- // When the repeat function is called with these inputs,
17+ // When the repeatStr function is called with these inputs,
1818// Then it should repeat the str count times and return a new string containing the repeated str values.
1919
2020test ( "should repeat the string count times" , ( ) => {
2121 const str = "hello" ;
2222 const count = 3 ;
23- const repeatedStr = repeat ( str , count ) ;
23+ const repeatedStr = repeatStr ( str , count ) ;
2424 expect ( repeatedStr ) . toEqual ( "hellohellohello" ) ;
2525} ) ;
2626
2727// case: handle Count of 1:
2828// Given a target string str and a count equal to 1,
29- // When the repeat function is called with these inputs,
29+ // When the repeatStr function is called with these inputs,
3030// Then it should return the original str without repetition, ensuring that a count of 1 results in no repetition.
3131
3232// case: Handle Count of 0:
3333// Given a target string str and a count equal to 0,
34- // When the repeat function is called with these inputs,
34+ // When the repeatStr function is called with these inputs,
3535// Then it should return an empty string, ensuring that a count of 0 results in an empty output.
3636
3737// case: Negative Count:
3838// Given a target string str and a negative integer count,
39- // When the repeat function is called with these inputs,
39+ // When the repeatStr function is called with these inputs,
4040// Then it should throw an error or return an appropriate error message, as negative counts are not valid.
4141const repeat = require ( "./repeat" ) ;
4242
0 commit comments