25% off

Use code FUNCMAIN at checkout for 25% off all premium courses.

Get started โ†’

Interactive Go ยท Lesson

Variables

Adventurers need somewhere to keep their gold, health, and gear. In Go, that somewhere is a variable. The quickest way to make one is the short declaration operator :=, which both declares the variable and infers its type from the value.

gold := 100      // an int
name := "Elara"  // a string

Your Quest

The program already declares baseHealth. Declare a second variable bonusHealth set to 50 so the program prints the total.

Expected output:

150

Hint

Use bonusHealth := 50 on the commented line. Go infers it’s an int.

Additional Scrolls of Wisdom