Commit d87ddbb

mo khan <mo.khan@gmail.com>
2019-10-24 02:11:29
Add times parameter
1 parent da86ef8
repeat.go
@@ -1,8 +1,8 @@
 package main
 
-func Repeat(character string) string {
+func Repeat(character string, times int) string {
   var repeated string
-  for i := 0; i < 5; i++ {
+  for i := 0; i < times; i++ {
     repeated += character
   }
   return repeated
repeat_test.go
@@ -4,7 +4,7 @@ import "testing"
 
 func TestRepeat(t *testing.T) {
   t.Run("default", func(t *testing.T) {
-    repeated := Repeat("a")
+    repeated := Repeat("a", 5)
     expected := "aaaaa"
 
     if repeated != expected {
@@ -24,6 +24,6 @@ func TestRepeat(t *testing.T) {
 
 func BenchmarkRepeat(b *testing.B) {
   for i := 0; i < b.N; i++ {
-    Repeat("a")
+    Repeat("a", 5)
   }
 }