Start learning free

LESSON 71 OF 404 · CONDITIONAL STATEMENTS

Comparison Operators in Go

Lesson

Comparison operators compare two values and produce a boolean result.

OperatorMeaning
==equal to
!=not equal to
<less than
<=less than or equal to
>greater than
>=greater than or equal to

grade := 8

if grade < 5 {
    fmt.Println("Failed the test")
} else {
    fmt.Println("Passed the test")
}

Assignment
Use a comparison to decide whether the grade is passing.


STEP 1 OF 3
    Ctrl + Enter to check