Go · Stage 3 – Making Decisions · Lesson 21 of 64

if Statements

Run one block only when its condition is true.

Go code

age := 14
if age >= 13 {
    fmt.Println("Teen account")
}
Line-by-line explanation
  1. Age is stored.
  2. The if condition needs no parentheses.
  3. The opening brace begins the block.
  4. The message runs because the condition is true.
  5. The closing brace ends the block.
Expected output
Teen account

This is the expected result.