An else block runs when the if condition is false.
passed := false
if passed {
fmt.Println("Passed the test")
} else {
fmt.Println("Failed the test")
}
Only one branch runs: the if body when passed is true, otherwise the else body.
Assignment
Complete the else branch so the failed message is printed when passed is false.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check
