diff --git a/iteration/iter.go b/iteration/iter.go new file mode 100644 index 0000000..1de0fc3 --- /dev/null +++ b/iteration/iter.go @@ -0,0 +1,12 @@ +package iteration + +const repeatTime = 5 + +// Repeat takes a string and repeat it 5 times +func Repeat(s string) string { + var res string + for i := 0; i < repeatTime; i++ { + res += s + } + return res +} diff --git a/iteration/iter_test.go b/iteration/iter_test.go new file mode 100644 index 0000000..fd7d5e6 --- /dev/null +++ b/iteration/iter_test.go @@ -0,0 +1,12 @@ +package iteration + +import "testing" + +func TestRepeat(t *testing.T) { + repeated := Repeat("a") + expected := "aaaaa" + + if repeated != expected { + t.Errorf("expected %q but got %q", expected, repeated) + } +}