mirror of
https://github.com/bootdotdev/fcc-learn-golang-assets.git
synced 2025-12-16 18:21:16 +00:00
first
This commit is contained in:
36
course/2-variables/exercises/10-conditionals/readme.md
Normal file
36
course/2-variables/exercises/10-conditionals/readme.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Conditionals
|
||||
|
||||
`if` statements in Go don't use parentheses around the condition:
|
||||
|
||||
```go
|
||||
if height > 4 {
|
||||
fmt.Println("You are tall enough!")
|
||||
}
|
||||
```
|
||||
|
||||
`else if` and `else` are supported as you would expect:
|
||||
|
||||
```go
|
||||
if height > 6 {
|
||||
fmt.Println("You are super tall!")
|
||||
} else if height > 4 {
|
||||
fmt.Println("You are tall enough!")
|
||||
} else {
|
||||
fmt.Println("You are not tall enough!")
|
||||
}
|
||||
```
|
||||
|
||||
## Assignment
|
||||
|
||||
Fix the bug on line `12`. The `if` statement should print "Message sent" if the `messageLen` is *less than or equal to* the `maxMessageLen`, or "Message not sent" otherwise.
|
||||
|
||||
### Tips
|
||||
|
||||
Here are some of the comparison operators in Go:
|
||||
|
||||
* `==` equal to
|
||||
* `!=` not equal to
|
||||
* `<` less than
|
||||
* `>` greater than
|
||||
* `<=` less than or equal to
|
||||
* `>=` greater than or equal to
|
||||
Reference in New Issue
Block a user