Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. "strings"
  6. )
  7.  
  8. func trim(text string) string {
  9. length := len(text)
  10.  
  11. if length <= 2 {
  12. return text
  13. }
  14.  
  15. return text[1 : length-1]
  16. }
  17.  
  18. func countVowel (text string) int {
  19. counter := 0
  20.  
  21. text = strings.ToUpper(text)
  22.  
  23. for index := range text {
  24. char := text[index]
  25. if ( char == 65 || char == 69 || char == 73 || char == 79 || char == 85 ) {
  26. counter += 1
  27. }
  28. }
  29. return counter
  30. }
  31.  
  32. func main() {
  33. // #1 https://dev.to/thepracticaldev/daily-challenge-1-string-peeler-4nep
  34. fmt.Println( trim("testing") )
  35. fmt.Println( trim("OH") )
  36.  
  37. // #3 https://dev.to/thepracticaldev/daily-challenge-3-vowel-counter-34ni
  38. fmt.Println(countVowel("aseiou"))
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement