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
EasyWe 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
1Introduction
Introduction3Play with Slices & Arrays
Longest StringDouble Even NumbersSum Average Minimum and MaxSumEven & Odd NumbersSlice to Map Non Repeated Indices