forked from root/public
Compare commits
4 Commits
master
...
DEV-3384-n
Author | SHA1 | Date |
---|---|---|
Tiago Collot | 6f7075ff99 | 2 years ago |
Tiago Collot | 3680cb5a7e | 2 years ago |
Tiago Collot | 15526c71fc | 2 years ago |
hamza | 1fe84e6d6d | 2 years ago |
1 changed files with 49 additions and 0 deletions
@ -0,0 +1,49 @@
|
||||
## iscapitalized |
||||
|
||||
### Instructions |
||||
|
||||
Write a function `IsCapitalized()` that takes a `string` as an argument and returns `true` if each word in the `string` begins with either an uppercase letter or a non-alphabetic character. |
||||
|
||||
- If any of the words begin with a lowercase letter return `false`. |
||||
- If the `string` is empty return `false`. |
||||
|
||||
### Expected function |
||||
|
||||
```go |
||||
func IsCapitalized(s string) bool { |
||||
|
||||
} |
||||
``` |
||||
|
||||
### Usage |
||||
Here is a possible program to test your function: |
||||
|
||||
```go |
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"piscine" |
||||
) |
||||
|
||||
func main() { |
||||
fmt.Println(piscine.IsCapitalized("Hello! How are you?")) |
||||
fmt.Println(piscine.IsCapitalized("Hello How Are You")) |
||||
fmt.Println(piscine.IsCapitalized("Whats 4this 100K?")) |
||||
fmt.Println(piscine.IsCapitalized("Whatsthis4")) |
||||
fmt.Println(piscine.IsCapitalized("!!!!Whatsthis4")) |
||||
fmt.Println(piscine.IsCapitalized("")) |
||||
} |
||||
``` |
||||
|
||||
And its output: |
||||
|
||||
```console |
||||
$ go run . |
||||
false |
||||
true |
||||
true |
||||
true |
||||
true |
||||
false |
||||
``` |
Loading…
Reference in new issue