Menu
Coddy logo textTech

Double Even Numbers

Lesson 10 of 24 in Coddy's Golang Challenges - Level 1 course.

Refer to these lessons if you forgot how the make keyword works with slices.

challenge icon

Challenge

Easy

We have an array like this: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

Write a function that takes an array of integers and returns a new slice with all the even numbers doubled and odd numbers left unchanged.

For example, in this case, the expected output should be:

[1, 4, 3, 8, 5, 12, 7, 16, 9, 20]

Try it yourself

func doubleEvenNumbers()  {


}

All lessons in Golang Challenges - Level 1