Menu
Coddy logo textTech

Recap Challenge #2

Lesson 16 of 21 in Coddy's Slices and Maps in Golang course.

challenge icon

Challenge

Easy

Write a program that takes a slice of numbers and prints the largest value in it.

  • In the given code, we define a slice of numbers. 
  • Using the <strong>range</strong> keyword, loop over the slice to find the largest value

Try it yourself

package main

import (
	"fmt"
)

func main() {
	// Define a slice of numbers Don't Change this!
	numbers := []int{34, 456, 200, 15, 30}

	// Initialize the variable to hold the maximum value
	

	// Iterate over the slice to find the maximum value


	// Print the maximum value
	fmt.Println("The maximum value:", max)
}

All lessons in Slices and Maps in Golang