We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b7caf06 commit 587c245Copy full SHA for 587c245
1 file changed
randomword.go
@@ -2,20 +2,26 @@ package randomtext
2
3
import (
4
"errors"
5
+ "math/rand"
6
"strings"
7
)
-
8
+func getRandomNumber() int {
9
+ return rand.Intn(3)+1
10
+}
11
func RandomWord(length uint, separator string) (string, error) {
12
if length == 0 {
13
return "", errors.New("length cannot be 0")
14
}
15
16
var words []string
17
for i := 0; i < int(length); i++ {
- if i%2 == 0 {
18
+ randomIndex := getRandomNumber();
19
+ if randomIndex == 1 {
20
words = append(words, Noun())
- } else {
21
+ } else if randomIndex == 2{
22
words = append(words, Adjective())
23
+ } else {
24
+ words = append(words, Animal())
25
26
27
0 commit comments