Menu
Coddy logo textTech

Recap - Variables and Types

Part of the Fundamentals section of Coddy's GO journey. Lesson 14 of 109.

challenge icon

Challenge

Easy

In this challenge, you'll practice working with different variable types in Go and printing them to the console.

You need to:

  1. Define a new integer variable named 'quantity' with value 5
  2. Print the product name with a label
  3. Print the quantity with a label

Make sure to use the variables in your print statements rather than hardcoding values where possible.

Expected output format:

Product: Coffee Mug
<code>Quantity: 5

Try it yourself

package main

import "fmt"

func main() {
  // Define given variables
  productName := "Coffee Mug"
  
  // TODO: Define a new integer variable named 'quantity' with value 5
  
  // TODO: Print the product name with a label: "Product: Coffee Mug"
  
  // TODO: Print the quantity with a label: the exact text from the instructions
}

All lessons in Fundamentals

Practice on your own: Online Go compiler