22 lines
373 B
Go
22 lines
373 B
Go
package iteration
|
|
|
|
import "strings"
|
|
|
|
const defaultRepeatCount = 5
|
|
|
|
func RepeatFive(character string) string {
|
|
return Repeat(character, defaultRepeatCount)
|
|
}
|
|
|
|
func Repeat(character string, count int) string {
|
|
if count == 0 {
|
|
count = defaultRepeatCount
|
|
}
|
|
var repeated strings.Builder
|
|
for range count {
|
|
repeated.WriteString(character)
|
|
}
|
|
|
|
return repeated.String()
|
|
}
|