An if statement lets a program run code only when a condition is true.
In Go, the condition is written after if, and the body is wrapped in curly braces:
passed := true
if passed {
fmt.Println("Passed the test")
}
You can add else to run different code when the condition is false:
if passed {
fmt.Println("Passed the test")
} else {
fmt.Println("Failed")
}
Assignment
Follow the Coding Tutorial and print the correct message based on passed.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
