Logical operators can be combined to express more complex rules.
Use parentheses to make the grouping clear:
specialStudent := false
age := 23
if specialStudent || (age >= 18 && age <= 30) {
fmt.Println("Let him in!")
} else {
fmt.Println("Not allowed")
}
This allows entry if the student is special, or if the age is between 18 and 30 inclusive.
Assignment
Combine || and && to check the entry rule.
Free plan: 30 tutor messages. PRO is unlimited.
Saved
Ctrl + Enter to check
