We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ed1a393 commit 93d9cb6Copy full SHA for 93d9cb6
1 file changed
Sprint-3/2-practice-tdd/repeat.js
@@ -1,5 +1,16 @@
1
-function repeat() {
2
- return "hellohellohello";
+function repeat(valueToRepeat, numOfTimes) {
+ let repeatedValue = "";
3
+ if (numOfTimes > 0) {
4
+ for (let i = 0; i < numOfTimes; i++) {
5
+ repeatedValue += valueToRepeat;
6
+ }
7
+ } else if (numOfTimes === 0) {
8
+ repeatedValue = "";
9
10
+ else {
11
+ repeatedValue = "Negative number invalid";
12
13
+ return repeatedValue;
14
}
15
16
module.exports = repeat;
0 commit comments